readyState not ready -- closed see google groups
I have written some code that creates one xmlhttp object and shares it among different functions. My problem is that I can get the code to run in IE but not Firefox when the asynchronicity is set to false and I use post. If I set asynchronicity to true then for some reason the httpreadyState is not ready and I get back either a 1 or 3 as a response code in both browsers, but if I add an alert within the code at the end of my loop, then readyState succeeds. Problem is that I don't want the alert in there as it kills my whole AJAX app usability. I have some code below to demonstrate.
Help is appreciated.
<div align="left">
/////BEGIN CODE
function getItAll() {
//This responseText is from another method.
var resultz = http.responseText;
//This looks at how many urls are in my data.
var num = countInstances(resultz, '<!--URL');
/*This is where I loop through the response text and get some data that I want to use in handleHttpResponse. The handleHttpResponse will look at the data(a url) and get information from it. All files(urls) are on the same server.*/
for (j=0; j < num;j++) {
var urlToCompare = resultz.substring(resultz.indexOf('<!--URL' + j + '#')+9);
var urlToCompare = urlToCompare.substring(urlToCompare,
urlToCompare.indexOf('#URL-->'));
http.open('POST', urlToCompare, true);
http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http.onreadystatechange = handleHttpResponse;
//Sending a random param to prevent caching.
http.send('?ms=' + new Date().getTime());
/*If I don't add this alert my readyState doesnt get to 4 and so my handleHttpResponse will not run or at least one just once and then die. It seems that by adding this alert I give the request/code a chance to catch up with itself. */
alert('test');
}
}
////////////END CODE
</div id="left">
|