http://bytes.com/forum/thread798289.html
Trying to trace the problem I have written a code (Separate from The Form Validation) which sends 300 requests with an interval of 10 miliseconds and displays the output. Now i face a very similar problem. The output is displayed only for the last request. This problem only occurs in Firefox, and the code works fine in IE7.
The code below is a PHP script (counter.php) provides output for ajax request
Expand|Select|Wrap|Line Numbers
- <?
- session_start();
- if($_SESSION['count']>0){
- $_SESSION['count']=$_SESSION['count']+1;
- }
- else{
- $_SESSION['count']=1;
- }
- echo $_SESSION['count'];
- ?>
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <title>Ajax Batch Request</title>
- <script language="javascript">
- var c=1;
- function sendRequest(){
- a=getAjaxObject();
- a.onreadystatechange=function(){
- if(a.readyState==4){
- output=a.responseText;
- var e=document.createElement('b');
- e.innerHTML='<br>'+output;
- document.body.appendChild(e);
- }
- }
- a.open("Get","counter.php",true);
- a.send(null);
- if(c<=299){
- setTimeout("sendRequest()",10);
- c++;
- }
- }
- function getAjaxObject(){
- var ajaxRequest;
- try{
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- alert("Your browser doesn't support ajax!");
- return false;
- }
- }
- }
- return ajaxRequest;
- }
- </script>
- </head>
- <body>
- <input type="button" value="send request" onclick="sendRequest()" />
- </body>
- </html>
If i change the interval on Line # 19 from 10 to 1000, everything works fine