Thetcm Posted August 21, 2009 Share Posted August 21, 2009 I'll just start by saying that the thing I'm working on is highly dynamic and has a lot of Ajax requests possible to get or send data to a database, and all my scripts work properly except for this one, even though it's exactly like the rest. function setSort(sor){ xmlHttp=GetXmlHttpObject(); if (xmlHttp==null){ alert ("Browser does not support HTTP Request"); return; } var url="setSort.php?sor="+sor; xmlHttp.onreadystatechange=function(){ //alert(xmlHttp.readyState); if(xmlHttp.readyState==4){ alert(xmlHttp.responseText); } } xmlHttp.open("GET",url,true); xmlHttp.send(null) } GetXmlHttpObject() is defined somewhere else and isn't the problem. As you can see, it's pretty straight foward. I send a request to setSort.php and I try to show the result in a alert box(that's not what I'm doing, but since it didn't work I tried this). The PHP is pretty standard too : <?php session_name(SESSION_NAME); session_start(); if(isset($_GET['sor'])) { $_SESSION['sort'] = $_GET['sor']; } echo $_SESSION['sort']; ?> I'm not even doing anything here, aside declaring a $_SESSION variable to be used in my call to show my list, in order to sort it properly. It couldn't be simpler. "sor", the data passed around, is actually the ID of the TD I clicked on. Standard stuff again. But the xmlHttp.onreadystatechange=function(){ //alert(xmlHttp.readyState); if(xmlHttp.readyState==4){ alert(xmlHttp.responseText); } } That way it's not doing anything. BUT if I remove the comments of the "//alert(xmlHttp.readyState);" line, the script seems to get that, yes, in fact, readyState did become 4 at some point, and does what it's supposed to. What's wrong? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.