473,516 Members | 3,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ajax and FireFox problem

Claus Mygind
571 Contributor
I have a problem with some ajax communications on some users' computers.

Sometimes data sent via ajax would not post to the database. I resolved the problem by deleting the user's profile and creating a new profile.

My dilemma is this, I don't know what part of the profile was creating the problem, so I don't know if it will reappear?

Here is what I do know (see my code below).

1. The query was always present in the query string being sent
2. The web server (Apache 2.2.10) shows a 200 code in the access log even though no post occurred on the database (MySQL 5.0 MyISAM storage engine).
3. If I set a breakpoint with firebug on line 51 (the test for the readyState) I could get it to post properly.

So it appears as if the script is running a little ahead thereby creating an incomplete query. And it is probably returning the 200 code because there is nothing on the server side app to trap and error if nothing occurs. That however is besides the point, the problem is the client side script in conjunction with the user's profile.

I know you can programatically control the user's firefox profile, but I am not sure which part I need to check or even how to check it?


Expand|Select|Wrap|Line Numbers
  1. var timeHttp;
  2.  
  3. function submitTime()
  4. {
  5.     if (window.ActiveXObject) 
  6.     {
  7.         timeHttp = new ActiveXObject("Microsoft.XMLHTTP");
  8.     }else if (window.XMLHttpRequest) {
  9.         timeHttp = new XMLHttpRequest();
  10.     }
  11.     var url = "/<myPath>/<myApp>?timeStamp=" + new Date().getTime();
  12.     var queryString = buildTime();
  13.     timeHttp.onreadystatechange = handleTimeStateChange;
  14.     timeHttp.open("POST", url, true);
  15.     timeHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  16. //---------------------------------
  17. When stopped here
  18. query was always present
  19. //---------------------------------
  20.     timeHttp.send(queryString);
  21. }
  22. function buildTime()
  23. {
  24.     qString = "Action="+document.getElementById("MySubmit").value; 
  25.  
  26.     for (var i = 0; i < aDailyTime.length; i++ )
  27.     {
  28.         qString += "&RECKEY"+i+"="+aDailyTime[i].RECKEY;
  29.         qString += "&EMPNO"+i+"='"+aDailyTime[i].EMPNO+"'";
  30.         qString += "&WORKDAY"+i+"="+aDailyTime[i].WORKDAY;
  31.         qString += "&PRJCTNAME"+i+"='"+encodeURIComponent(aDailyTime[i].PRJCTNAME)+"'";
  32.         cTotTime = parseFloat(aDailyTime[i].HOURS)+parseFloat(aDailyTime[i].minutes);
  33.         qString += "&STARTMILES"+i+"=";
  34.         qString += ( aDailyTime[i].STARTMILES == "" ) ? 0 : aDailyTime[i].STARTMILES;
  35.         qString += "&ENDMILES"+i+"=";
  36.         qString += ( aDailyTime[i].ENDMILES == "" ) ? 0 : aDailyTime[i].ENDMILES;
  37.         //if "--->" is found in project name then this employee's departmetn is not assigned to this job's department
  38.         cIsDept  = ( aDailyTime[i].PRJCTNAME.substring(0,4) == "--->" ) ? 'F' : 'T';
  39.         qString += "&isDept"+i+"='"+ cIsDept +"'";
  40.     }
  41.     qString += "&method=POST";
  42.     return qString;
  43. }
  44.  
  45. function handleTimeStateChange() 
  46. {
  47. //----------------------------------------
  48. This is where the problem would
  49. occur.  Not sure why?
  50. //---------------------------------------
  51.     if (timeHttp.readyState == 4) 
  52.     {
  53.         if (timeHttp.status == 200) 
  54.         {
  55.             parseTimeResults();
  56.         }
  57.     }
  58. }
  59.  
  60. function parseTimeResults() {
  61.  
  62.     var returnedString = timeHttp.responseText;
  63.     var aReturn = new Array();
  64.     aReturn = returnedString.split(';');
  65.     if ( aReturn[0] == "An error occured") 
  66.     { 
  67.         eAlert  = aReturn[0]+"\n"
  68.  
  69.         if ( aReturn[1] == "Error on time submittal") { 
  70.             eAlert += aReturn[1]+" "+document.getElementById("EMPNO").value
  71.         }else{ 
  72.             eAlert += aReturn[1]+"\n"
  73.             eAlert += aReturn[2]+"\n"
  74.             eAlert += aReturn[3]+"\n"
  75.             eAlert += aReturn[4]
  76.         }
  77.  
  78.         alert( eAlert );
  79.  
  80.     }else{ 
  81.         alert( aReturn[0] );
  82.     }
  83. }
  84.  
  85.  
Apr 17 '09 #1
4 1975
acoder
16,027 Recognized Expert Moderator MVP
Since you deleted and created a new profile, has the problem ever occurred again?
Apr 21 '09 #2
Claus Mygind
571 Contributor
@acoder
Yes the problem did re-occur. But just now I have been able to solve the problem. As usual it was within my own code although I still do not understand what or why it did what it did.

I was combining some of my pre-ajax code with my current ajax code when submitting a record.

My action property for the form was set at action = "return false;" to prevent the enter button from submitting the form. This is standard in all my apps as I do some validation on the form before submitting. But in using the ajax approach to send only the data and not the form to the web server, the faulty code crossed the function with the "form.submit();" line which it should not have. There was no specific action or url for the form.submit() to execute but it seemed to mess up the "readyState" on the ajax where it seems nothing was submitted at all. I can accept and understand all that. But what baffles me is the access log on the web server shows that the receiving program was called and executed with a return code of 200. Well I have eliminated the cross link and the problem has been solved.

Thank you for checking in on me
Apr 24 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
@Claus Mygind
Not sure exactly what the problem might have been, but I can say that there's no need for this as long as you call your validation function onsubmit:
Expand|Select|Wrap|Line Numbers
  1. <form ... onsubmit="return validate();">
If you return false when validation fails, then the form would not be submitted, thus you can set a correct action and don't need to call the submit() method.
Apr 24 '09 #4
Claus Mygind
571 Contributor
Thanks for your help.
Apr 27 '09 #5

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

Similar topics

5
20051
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great with Firefox,but with IE6 the onFailure never gets called and the request never completes. My code: var ajaxReq = new Ajax.Request( url,...
4
7447
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole new page that should replace an existing one. I.e when we issue an Ajax request we don't know what will be returned and analyze the response to act...
3
2962
by: noballack | last post by:
I've got a problem, I'm working with Ajax in a web with a form with a list of checkbox added to the form via an Ajax.Updater method. These added checkboxs are not been sended by the form if I use Firefox or Safari. My source code is something like that: <script type="text/javascript"...
17
11839
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);" onclick="show('ajaxrequest.php?action=removefield','div1');show('ajaxrequest.php?action=reloaddiv2','div2')">verwijderen</a> While both seperate actions work they dont when I put them together. Anyone know how to fix this ? My ajax.js with funcition...
2
4534
by: germ | last post by:
doing a simple page webmethod call an a page via PageMethods works fine in ie7 & opera9 the same call on firefox ( and I assume netscape ) generates the following error : Error: " nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::...
2
3131
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand...
8
3126
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" post. Third, there are pieces of this code that I am not at liberty to display, change, discuss, or re-implement. As far as this question is...
29
3279
by: zalek | last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET", url, false). I noticed that in FireFox handler doesn't starts. It starts when I use xmlHttp.open("GET", url,true). I need to use it in sync mode. Any ideas what can I do? Thanks, Zalek.
2
1637
by: burtonfigg | last post by:
I'm testing an ajax page - this works fine in Firefox: http://jimpix.co.uk/clients/a/ecards/defaultx.asp Click on any of the links on the right under the 'occassions' or 'others' headings, in Firefox, and thumbnails appear based on what you clicked on. Do the same in IE6, and it returns an error: Line: 71 Char: 9 Error: Unknown...
3
17665
by: George | last post by:
I am doing an AJAX call using JQuery on my page to which returns JSON objects and everything works fine. Now I decided to use ashx handler instead of and simply write JSON out. Then my problems begun. So here is JQuery call $.ajax({ type: 'POST', url: url,
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7574
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7547
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3265
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.