473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with Firefox and Ajax batch requests

rizwan6feb
108 100+
Hi experts! Recently i was working on "Form Validation Using Ajax". My form validation was creating problem, when a user changes focus too quickly. I had a post related to this, but was unable to solve the problem. Here is the previous post
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
  1. <?
  2.     session_start();
  3.     if($_SESSION['count']>0){
  4.         $_SESSION['count']=$_SESSION['count']+1;
  5.     }
  6.     else{
  7.         $_SESSION['count']=1;
  8.     }
  9.     echo $_SESSION['count'];
  10. ?>
  11.  
The code below is HTML to send batch requests

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Ajax Batch Request</title>
  4. <script language="javascript">
  5.     var c=1;
  6.     function sendRequest(){
  7.         a=getAjaxObject();
  8.         a.onreadystatechange=function(){
  9.             if(a.readyState==4){
  10.                 output=a.responseText;
  11.                 var e=document.createElement('b');
  12.                 e.innerHTML='<br>'+output;
  13.                 document.body.appendChild(e);
  14.             }
  15.         }
  16.         a.open("Get","counter.php",true);
  17.         a.send(null);
  18.         if(c<=299){
  19.             setTimeout("sendRequest()",10);
  20.             c++;
  21.         }
  22.     }
  23.     function getAjaxObject(){
  24.         var ajaxRequest;
  25.         try{
  26.             ajaxRequest = new XMLHttpRequest();
  27.         } catch (e){
  28.             try{
  29.                 ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  30.             } catch (e) {
  31.                 try{
  32.                     ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  33.                 } catch (e){
  34.                     alert("Your browser doesn't support ajax!");
  35.                     return false;
  36.                 }
  37.             }
  38.         }
  39.         return ajaxRequest;
  40.     }
  41.  
  42. </script>
  43. </head>
  44.  
  45. <body>
  46.     <input type="button" value="send request" onclick="sendRequest()" />
  47. </body>
  48. </html>
  49.  
  50.  

If i change the interval on Line # 19 from 10 to 1000, everything works fine
Jun 7 '08 #1
3 2583
gits
5,390 Expert Mod 4TB
as you should see ... you loose the references again everytime you start a new request. since you don't use the var keyword you use a global variable and assign a new request before it has processed properly. try to store the references as i suggested the last time.
Jun 7 '08 #2
rizwan6feb
108 100+
Thanks gits! You are right, I was missing the 'var' keyword on line# 7. You gave me the idea of arrays in the last post, which i was unable to implement in my code. But this time i hope there will be no problem
Jun 7 '08 #3
gits
5,390 Expert Mod 4TB
please show your attempt and tell where you have problems ...

kind regards
Jun 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
1
by: Gerald Stampfel | last post by:
Hi, i am doing ajax requests to an IIS server. the response is a JSON string, stored in xml.responseText. in IE everything is fine. in firefox, only a part (80%) of the string is delievered in 8...
1
by: quill | last post by:
Hi I am making a chatroom script and it appears that the problem seems to be that my setTimeout's are conflicting. The logic is as follows: Run a login check every x seconds Run a trigger...
14
by: FMDeveloper | last post by:
Currently transitioning from a shared host to a dedicated server. The same code that works on the old server is not working on the dedicated server. It is a simple AJAX request like: <code>...
16
by: Victor | last post by:
I have a strange problem in my website. I configured my website to run under 2 worker processes. (web garden enabled). and I stored my user information in the current httpcontext(like...
0
by: jrnail23 | last post by:
I have a user control which contains an UpdatePanel, which contains a MultiView inside, with a GridView in one of the views. In my GridView, I have a ButtonField which is supposed to trigger a...
0
by: tlc | last post by:
Hi there, I'm new to the AJAX framework, and trying to find a way to do something that perhaps is not part of the AJAX framework. I have a data entry page that keeps allowing a user to enter a...
1
by: Christoph Boget | last post by:
I'm experiencing a very odd problem and it's happening only in IE6. IE7, Safari, Opera and Firefox are all working properly. What's happening is that I'm using XHR request responses to update the...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.