XMLHttpRequest does not fire the readystatechange event when used inside a wrapper function




13 years ago
6 years ago


(Reporter: alein, Unassigned)


Windows 2000

Firefox Tracking Flags

(Not tracked)




(1 attachment)



13 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6

I've created a simple wrapper function/object which creates an instance of the
XMLHttpRequest object as one of it's properties.  When using the XMLHttpRequest
as an extention to my simple wrapper object, it will not fire the
readystatechange event if the xml file is opened using a Syncronious request. 
However, it will work for Asyncronious requests.

Reproducible: Always

Steps to Reproduce:
1. Go to the page I've supplied: http://www.baka.ca/test/sjax.htm
2. The effect is automatic.
3. Click the relod link to call the javascript function again.
Actual Results:  
1. When the window loads, it will call a function that will show the error.
2. The first alert() box will show what should be returned every time.
3. The second alert() box shows nothing.

Expected Results:  
The second alert() should display the same content as the first alert() box.
Assignee: events → general
Component: DOM: Events → DOM: Mozilla Extensions
You have this code:
this.xmlobj.onreadystatechange = function() { this.stuff =
this.xmlobj.responseText }
I think you've done something wrong here.
The 'this' in this.stuff is basically this.xmlobj

Comment 2

13 years ago
oops, typo (i was messing with it quite a bit.

"this.stuff" was the old property i was using, its now "this.response".

i changed the lines to read:
function tmp() {
	this.response = ""
	this.xmlobj = new XMLHttpRequest()
	this.xmlobj.onreadystatechange = function() { this.response =
this.xmlobj.responseText }

in theory, the this.xmlobj should fire a readystatechange event. also, nothing
should process until the testing.htm file is loaded (since its supposed to be
Created attachment 194432 [details]

I think I understand now. This is a correct testcase of what you think should
happen, not?
Hmm, current trunk build freezes on the testcase (Mozilla1.7 not).
You have to download the testcase and test it locally with a trunk build.

Comment 5

13 years ago
yes, your testcase should work, and does work in Opera 8 (cant test IE6 because
it does not support the XMLHttpRequest object).

oddly, this testcase also doesnt seem to work in FF right now, I thought this
bug was limited to events which were wrapped inside objects/functions.
(im using FF 1.0.6)

Comment 6

13 years ago
i just modified my test file (http://www.baka.ca/test/sjax.htm) which includes a
small fix. it should fire and return properly in Opera 8 now too.

Comment 7

13 years ago
Are you sure about this?

Mozilla does not trigger the readystatechange events when you are using sync loading:

open(sMethod, sUri, bAsync)

So maybe this bug is INVALID and another one should be used covering not firing the event for sync loading?

Comment 8

13 years ago
I've done a lot more investigation, and you are right.  The bug stems from the lack of the readystatechange event in sync mode, and not the wrapper.

I submitted a new bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=313646


13 years ago
Last Resolved: 13 years ago
Resolution: --- → INVALID
Component: DOM: Mozilla Extensions → DOM
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.