Reading this (
http://www.quirksmode.org/blog/archives ... s_a_1.html ) suggests it's because the XMLHttpRequest object is busy. I doubted this because this happens even on first page load. In any case I wrote an object to handle this better and ensure that the XMLHttpRequest object in use is a fresh copy.
Code: Select all
function XMLHttpObj()
{
this.xmlHttpArray = new Array();
this.newXmlHttp = function()
{
var XMLHttp;
if (window.XMLHttpRequest) XMLHttp = new XMLHttpRequest();
else if (window.ActiveXObject)
{
try {
XMLHttp = new window.ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
XMLHttp = false;
}
}
else XMLHttp = false;
return XMLHttp;
}
this.addNewInstance = function()
{
this.xmlHttpArray.push(this.newXmlHttp());
}
this.getCurrentInstance = function()
{
return this.xmlHttpArray[this.xmlHttpArray.length-1];
}
//Construct
this.addNewInstance();
//End construct
}
var myXMLHttp = new XMLHttpObj();
Still no banana.
Then I decided to add an alert to check if it was indeed the readyState that's busy:
Code: Select all
function killIt(el, el2)
{
var theID = el2.id.replace(/^linkid_(.*)$/, "$1");
//alert(theID);
myXMLHttp.getCurrentInstance().open("GET", ('index.php?___stub_only&killit='+theID), true);
myXMLHttp.getCurrentInstance().onreadystatechange = relistBlurbs;
alert(myXMLHttp.getCurrentInstance().readyState);
myXMLHttp.getCurrentInstance().send(false);
el.removeChild(el2);
return true;
}
I get an alert that indicates readyState = 0. That's good... that means it's a new instance and waiting for orders
Yet, I still get the error:
Code: Select all
Error: uncaught exception: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: http://iris/shane-dev2/index.php?___sys_op___=link&___link___=144 :: killIt :: line 195" data: no]
For info reagrding readyState to anyone JS happy but not used to AJAX.
0 = Idle, ready for anything
1 = Loading
2 = Sending/dealing with headers
3 = Downloading data
4 = Finished downloading, ready for next command
onreadystatechange is simply the event that happens when the readyState changes from 0 to 1 to 2 to 3 to 4 etc....
Hoping someone may have found a better article that offers other solutions than quirks mode does.