Closed Bug 306487 Opened 19 years ago Closed 19 years ago

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

Categories

(Core :: DOM: Core & HTML, defect)

All
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: alein, Unassigned)

References

()

Details

Attachments

(1 file)

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
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 }
	this.xmlobj.open("GET","testing.htm",false)
	this.xmlobj.send(null)
}

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
syncronious).
Attached file testcase
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.
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)
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.
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?
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
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: