bobleny Posted November 19, 2007 Share Posted November 19, 2007 I have a script that looks much like this... index.php <html> <head> <script type="text/javascript"> <!-- var GetServer function Connect() { try { // Firefox, Opera 8.0+, Safari GetServer = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { GetServer = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { GetServer = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { return false; } } } } function Check() { Connect(); GetServer.onreadystatechange=function() { if(GetServer.readyState == 4) { document.getElementById("echo").innerHTML = GetServer.responseText; Retrieve(); } } var site = "page_2.php"; GetServer.open("GET",site,true); GetServer.send(null); } Check(); --> </script> </head> <body> <span id="echo"></span> </body> </html> page_2.php <?php echo "foo<br />"; sleep(60); echo "fooy"; ?> OK, this script should echo foo, wait 1 minute, and echo fooy; in that order. But that's not what it does, it waits 1 minute, then echos foo and fooy at the same time. Is there a way to make it echo foo, wait 1 minute, and then echo fooy? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2007 Share Posted November 19, 2007 well as per my knowlegde ajax waits for the script to finish execution so when it does it will give you both the variables,what your looking for should be two scripts governed by javascript not php so the first script you call echos foo and the second one you call echos fooy so you have to have the sleep in javascript not php 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.