
xmlhttprequest - issue #2
Upper level variables not getting synchronized correctly in Firefox/2.0.0.9
My Code: var request = new XMLHttpRequest; request.open("GET", "get_ip.php", false); request.onreadystatechange = function(){;} request.send(null);
I'm trying to do a synchronous GET. Output of the request object yields:
request[_object] =
_object[onreadystatechange] =
_object[open] = [function]
_object[send] = [function]
_object[channel] =
_object[responseXML] = undefinednull
_object[responseText] = 127.0.0.1
_object[status] = 200
_object[statusText] = OK
_object[abort] = [function]
_object[getAllResponseHeaders] = [function]
_object[getResponseHeader] = [function]
_object[setRequestHeader] = [function]
_object[readyState] = 4
_object[overrideMimeType] = [function]
_object[multipart] = false
_object[onload] = undefinednull
_object[onerror] = undefinednull
_object[onprogress] = undefinednull
_object[addEventListener] = [function]
_object[removeEventListener] = [function]
_object[dispatchEvent] = [function]
_object[getInterface] = [function]
request[_async] = false
request[readyState] = 5
request[onreadystatechange] = [function]
request[responseText] =
request[responseXML] = null
request[status] = 0
request[statusText] =
request[open] = [function]
request[send] = [function]
request[abort] = [function]
request[getAllResponseHeaders] = [function]
request[getResponseHeader] = [function]
request[setRequestHeader] = [function]
request[toString] = [function]
As you can see, the _object seems to be updated correctly, however the none of the request variables, such as request.responseText, seem to be updated correctly. This works great in IE7. I'm also thinking that the readyState = 5 is a little suspect.
What version of the product are you using? On what operating system? Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 Windows XP Professional Firebug enabled/disabled does not matter, same results above.
Please provide any additional information below. There's a very good chance I'm doing something wrong. I've looked through your code to try to find determine a fix but after a day of trying, I thought that you might have a easy solution or be able to show me what I'm doing wrong.
Thanks for sharing this code. If I can get it to work, it'll be a life saver!
Comment #1
Posted on Nov 19, 2007 by Grumpy MonkeyComment deleted
Comment #2
Posted on Nov 20, 2007 by Grumpy MonkeyComment deleted
Comment #3
Posted on Nov 21, 2007 by Grumpy MonkeyAfter a bit of trying I was able to find a solution: cXMLHttpRequest.prototype.send = function(vData) { // Add method sniffer if (cXMLHttpRequest.onsend) cXMLHttpRequest.onsend.apply(this, arguments);
this._object.send(vData);
//supports synchronous sends
if(this._object.readyState == cXMLHttpRequest.DONE)
fSynchronizeStates(this);
// BUGFIX: Gecko - missing readystatechange events
if (!this._async && !bFireBug)
while (this.readyState++ < cXMLHttpRequest.DONE)
fReadyStateChange(this);
};
Comment #4
Posted on Nov 21, 2007 by Swift Monkey(No comment was entered for this change.)
Comment #5
Posted on Nov 21, 2007 by Swift Monkey(No comment was entered for this change.)
Comment #6
Posted on Nov 21, 2007 by Swift MonkeyThanks for the report. Issue is fixed now, also fixed "aborting" during readystatechange in synchronous requests.
Status: Fixed
Labels:
Type-Defect
Priority-High