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? -
var timeHttp;
-
-
function submitTime()
-
{
-
if (window.ActiveXObject)
-
{
-
timeHttp = new ActiveXObject("Microsoft.XMLHTTP");
-
}else if (window.XMLHttpRequest) {
-
timeHttp = new XMLHttpRequest();
-
}
-
var url = "/<myPath>/<myApp>?timeStamp=" + new Date().getTime();
-
var queryString = buildTime();
-
timeHttp.onreadystatechange = handleTimeStateChange;
-
timeHttp.open("POST", url, true);
-
timeHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-
//---------------------------------
-
When stopped here
-
query was always present
-
//---------------------------------
-
timeHttp.send(queryString);
-
}
-
function buildTime()
-
{
-
qString = "Action="+document.getElementById("MySubmit").value;
-
-
for (var i = 0; i < aDailyTime.length; i++ )
-
{
-
qString += "&RECKEY"+i+"="+aDailyTime[i].RECKEY;
-
qString += "&EMPNO"+i+"='"+aDailyTime[i].EMPNO+"'";
-
qString += "&WORKDAY"+i+"="+aDailyTime[i].WORKDAY;
-
qString += "&PRJCTNAME"+i+"='"+encodeURIComponent(aDailyTime[i].PRJCTNAME)+"'";
-
cTotTime = parseFloat(aDailyTime[i].HOURS)+parseFloat(aDailyTime[i].minutes);
-
qString += "&STARTMILES"+i+"=";
-
qString += ( aDailyTime[i].STARTMILES == "" ) ? 0 : aDailyTime[i].STARTMILES;
-
qString += "&ENDMILES"+i+"=";
-
qString += ( aDailyTime[i].ENDMILES == "" ) ? 0 : aDailyTime[i].ENDMILES;
-
//if "--->" is found in project name then this employee's departmetn is not assigned to this job's department
-
cIsDept = ( aDailyTime[i].PRJCTNAME.substring(0,4) == "--->" ) ? 'F' : 'T';
-
qString += "&isDept"+i+"='"+ cIsDept +"'";
-
}
-
qString += "&method=POST";
-
return qString;
-
}
-
-
function handleTimeStateChange()
-
{
-
//----------------------------------------
-
This is where the problem would
-
occur. Not sure why?
-
//---------------------------------------
-
if (timeHttp.readyState == 4)
-
{
-
if (timeHttp.status == 200)
-
{
-
parseTimeResults();
-
}
-
}
-
}
-
-
function parseTimeResults() {
-
-
var returnedString = timeHttp.responseText;
-
var aReturn = new Array();
-
aReturn = returnedString.split(';');
-
if ( aReturn[0] == "An error occured")
-
{
-
eAlert = aReturn[0]+"\n"
-
-
if ( aReturn[1] == "Error on time submittal") {
-
eAlert += aReturn[1]+" "+document.getElementById("EMPNO").value
-
}else{
-
eAlert += aReturn[1]+"\n"
-
eAlert += aReturn[2]+"\n"
-
eAlert += aReturn[3]+"\n"
-
eAlert += aReturn[4]
-
}
-
-
alert( eAlert );
-
-
}else{
-
alert( aReturn[0] );
-
}
-
}
-
-
4 1975 acoder 16,027
Recognized Expert Moderator MVP
Since you deleted and created a new profile, has the problem ever occurred again?
@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
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: - <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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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,...
|
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...
|
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"...
|
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...
|
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 ::...
| |
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...
|
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...
|
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.
|
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...
|
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,
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |