addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwchatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-crosscrosseditemptyheartfacebookfolderfullheartglobegmailgoogleimagesinstagramlinklocation-pinmagnifying-glassmailminusmoremuplabelShape 3 + Rectangle 1outlookpersonplusprice-ribbonImported LayersImported LayersImported Layersshieldstartrashtriangle-downtriangle-uptwitteruseryahoo

JaxPHP / JaxWeb Message Board › Can anyone answer this one? httpObject.readyState == 0

Can anyone answer this one? httpObject.readyState == 0

A former member
Post #: 122
I am recoding many things but had a problem with the old with random readystate of 0 (zero) being returned by Ajax requests. This works most the time so disabled the alert message. Research indicates that it could be a race issue with what javascript is deciding what to do and possible other page html such as forms. No real answers other than that this happens in Jquery also and still no good answer to why this happens?

Example of the old code:
<a class="nolineb" title="" onclick="doWork9('zplsst', 'hp', 'u', 'location', 'category', 'table', 'a');" >TOP</a>

function getHTTPObject(){
if (window.XMLHttpRequest) return new XMLHttpRequest();
else if (window.ActiveXObject) return new ActiveXObject("Msxml2.XMLHTTP"­);
else if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"­);
else {
alert("Your browser does not support AJAX.");
return null;
}
}

function ajaxTimeout(){
httpObject.abort();
}

function setOutput(dvnmbr){
var xhrTimeout=setTimeout("ajaxTimeout(­);",5000);
if(httpObject.readyState == 4){
if(httpObject.status == 200) {
clearTimeout(xhrTimeout);
var response = httpObject.responseText;
document.getElementById(dvnmbr).innerHTM­L = response;
}
else {
// alert("Please Try again we will fix this soon" + httpObject.status);
return;
}
}

var divblk = document.getElementById(dvnmbr);
divblk.style.display = 'block';

document.getElementById(dvnmbr).focus(­);

}

function doWork9(dvnmbr, ajax1, ajax2, bttn1, bttn2, bttn3, bttn4){
httpObject = getHTTPObject();

var url = "index.php?page=xx";
var params = "ajax1="+ajax1;
var params = params+"&ajax2="+ajax2;
var params = params+"&bttn1="+bttn1;
var params = params+"&bttn2="+bttn2;
var params = params+"&bttn3="+bttn3;
var params = params+"&bttn4="+bttn4;
var i = 1;
while(i < 50){

var inptt;
if (document.getElementById && (inptt =
document.getElementById('input'+i))) {
var inptx = inptt.value;
var params = params+"&input"+i+"="­+inptx;
i++;
}
else{
var i = 99;
}
}

if (httpObject != null) {
httpObject.open("POST", url, true);
httpObject.setRequestHeader("Cont­ent-type", "application/x-www-form-urlencoded"­);
httpObject.setRequestHeader("Cont­ent-length", params.length);
httpObject.setRequestHeader("Conn­ection", "close");
httpObject.send(params);
httpObject.onreadystatechange = function() { setOutput(dvnmbr); }
} }

Firebug provides no real help other than stating that request was aborted




Like said, I am not seeing on the new test site but would like to know why this happens.

Thank you for any ideas.
Tim

A former member
Post #: 123
I looked for an RFC on Ajax but there does not seem to be one. The only documentation seems to be on W3C for XMLHttpRequest. Guess have to go through my million e-books to find the inner workings of Ajax.
A former member
Post #: 134
I think I figured the answer on my own but now finding the cure to the cause! I do not know if there is one as it seems that most Jquery and drupal answers seem to be to silence the error.

Hmmmm, Actually using one of my freebie programs exposed the cause!

Tim
A former member
Post #: 135
What seems to be the problem!

Though browsers allow more connections these days open, they do not close instantly and that delay can leave no connection for too another Ajax requests called too close together.

The Two HTTP Connection Limit Issue

Tim
A former member
Post #: 138
Feel like I am talking to myself! This is not solved yet.

Okay this was my latest round and results. Using Wireshark, Smartsniff, TCPview and a couple other programs. It seems that an certain parts of an Ajax request will not force the connection to stay open and if the object is created right before the connection closes it will create the object but destroy the object as the connection resets. I am almost read to pull out an old copy of Etherpeek to see why the connection .



Tim

Alan would usually say something close or his concept and that would help turn my light on but feel no one here is quite understanding the question or problem? I am looking into polling methods as a solution.

Eric N.
user 4016762
Group Organizer
Orange Park, FL
Post #: 80
Tim,

I've been watching, but clueless.

I've been using Ajax more selectively lately, with no surprises. But even on some pretty Ajax-heavy apps in the past, I can't recall having this problem.

Eric
A former member
Post #: 141
The TOP-0-9-A-Z buttons are where am seeing it.

This is the live example:
ZipOnOver, Boston, MA

It seemed to show up when I changed Ajax from GET to POST months back. W3C recommends GET for requesting information and POST for sending, so I may try changing it back to GET where security is not an issue.

Tim
But thanks Eric, I will keep working on it here and there as I have a couple months before I am done my rewrite. And will reply when I find the solution (other than remove Ajax from this section as it does not have to be Ajax) I am in the middle of a 5 day data filtering process so have time at the moment to play with it.

Powered by mvnForum

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy