473,666 Members | 2,010 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 1989
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
20066
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, {method: 'post', parameters:
4
7458
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 accordingly. Now, the way to replace the current document with a new one used to be easy and...
3
2976
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" src="http://www.my_web_page.com//js/prototype-1.4.0.js"></script> <script> function showMoreOptions( url, pars, div_id ){ if...
17
11858
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 show
2
4547
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 :: http://hgha.gerzio.ca/ScriptResource.axd?d=3Ot8FdrYMQ58gwjNF6tbd8V5YtBKDtb8a6qI5cjRJWaZBQhYu2jjDRnc7N0IverhgY8x7LACpAIvqLPvNyERF0ui1Tz1p-s2eu0h41S_qMA1&t=633179517344763787 ::...
2
3152
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 whats the prob.this is the code i m using: <? include("config.inc.php"); //error_reporting(0); ...
8
3134
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 concerned, this means that (1) I cannot use 3rd party libraries, which is why I've implemented my own...
29
3302
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
1653
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 runtime error
3
17682
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
8356
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8640
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.