View Single Post
Old 11-29-2010, 12:50 AM   PM User | #18
sgpayn0
New to the CF scene

 
Join Date: Nov 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sgpayn0 is an unknown quantity at this point
resolved

I resolved my own problem, stumbled upon the bug...bad data in bad data out of course. As you can see in my function I pass it a string, turns out my AJAX code is perfectly fine, the string was not being fully reset before being passed back in for the 2nd iteration...

Quote:
I am expereicing the identical problem of AJAX only executing once. I was hopeful when I read this thread, particularly Alien51's response, but it isn't working for me.

Here is my code below...any help would be much appreciated. It works perfectly the first time, then nothing. I even tried adding the random parameter to be passed, still nothing...

Code:
  function AJAX()
  {
  var ajaxRequest;  // The variable that makes Ajax possible!

  try{
  // Opera 8.0+, Firefox, Safari
  ajaxRequest = new XMLHttpRequest();
  }
  catch (e)
  {
  // Internet Explorer Browsers
  try{
  ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e) {
  try{
  ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e){
  // Something went wrong
  alert("Your browser sucks, and doesn't support AJAX!");
  return false;
  }
  }
  }
  return ajaxRequest;
  }

  function div_details(str)
  {
  var divid = "details";
  var url = "StockDetails_ajax.jsp";

  // Create xmlHttp
  var xmlHttp_one = AJAX();
  if(xmlHttp_one==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

  xmlHttp_one.open("POST",url + str + "&r="+ Math.random(),true);
  xmlHttp_one.onreadystatechange=function()
  {
  if(xmlHttp_one.readyState==4 && xmlHttp_one.status==200)
      {
         document.getElementById(divid).innerHTML=xmlHttp_one.responseText;
      }
    }
    xmlHttp_one.send(null); 
    
  }

Last edited by sgpayn0; 11-29-2010 at 11:39 PM.. Reason: I found my error
sgpayn0 is offline   Reply With Quote