How To Invoke Three Ajax Functions Together?
Below is the code in my asp page Ajax.asp Ajax.asp
Solution 1:
I can't really see where your problem is, so it must be in your asp page. I'm sorry to say that I can't have a way of testing asp at the moment, so I can't help there. but, I wrote a fake delay in PHP and run your javascript. Here's what I used to test:
<?
if (isset($_GET['SECOND'])) {
for($i=0;$i<$_GET['SECOND']*100000;$i++) {
$x = sqrt($i);
}
echo $_GET['SECOND'].': x='.$x;
die();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Ajax.asp</title>
<script type="text/javascript">
function Delay(SECOND)
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest(); }
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('output').innerHTML += xmlHttp.responseText + "<br />";
}
}
xmlHttp.open("GET","ajax-test.php?SECOND="+SECOND,true);
xmlHttp.send(null);
return true
}
</script>
</head>
<body>
// below is the button for passing seconds
<input onclick="javascript:return (Delay('30')&& Delay('10')&& Delay('5'));" type="button" value="Button" name="B3">
<div id='output'></div>
</body>
</html>
The PHP part (at the top) basically is just to waste some time, depending on the SECONDS value. Though, it really only takes about 1/6th the amount of time requested. Here is the output from running the script:
5: x=707.106074079
10: x=999.9995
30: x=1732.05051889
Basically, this is just showing that 5 DELAY(5) is returning before DELAY(10) which is returning before DELAY(30), even though they are being requested in the opposite order.
So, take a look at your asp delay code, as the problem must be there. Sorry I can't help much otherwise.
Post a Comment for "How To Invoke Three Ajax Functions Together?"