Jump to content

readystate 4 not fired?


tom-kester

Recommended Posts

Hey all, I am new to ajax and am having some problems with it.

 

var xmlhttp;
function getgrain2(grid, sender) {alert(grid); alert(sender); alert(sender.parentNode); alert(sender.parentNode.parentNode);}
function getGrain(grid, sender)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
  var cell = sender.parentNode;
  var row = cell.parentNode;
var url="getgrain.php";
url=url+"?grid="+grid;
xmlhttp.onreadystatechange=stateChanged(row);
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged(row)
{

if (xmlhttp.readyState==4)
{
document.write(xmlhttp.responseText);
var result = xmlhttp.responseText;
var split = result.split("-");
var protien = split[0];
var fat = split[1];
var fiber = split[2];

}

}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

 

 

my issue is that I never seem to get into the if readystate == 4 section of the code.

 

I have done some research with no luck. I have used firebug and it shows that I have gotten a response, but I can't cause an alert with that response. Anyone able to point me in the right direction?

 

Thanks in advance.

 

Tom

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.