Ticket #9324 (closed bug: duplicate)
Odd handling of 'onreadystatechange' event in jqXHR when readyState > 1
|Reported by:||anonymous||Owned by:|
The doc at http://api.jquery.com/jQuery.ajaxPrefilter/ notes that prefilters give access to the jqXHR object (through which the native XHR should be accessible), but it seems like handlers attached to the XHR's onreadystatechange event act unexpectedly when readyState is > 1. http://bugs.jquery.com/ticket/8327 notes a jsfiddle providing a workaround to access some properties of the native XHR before readyState == 4, but the proposed solution seems inefficient: updates to the XHR's responseText are detected by polling that attribute every millisecond.
Instead, I think it would be better to simply add an event handler to the onreadystatechange event, and detect when readyState==3. I've tried doing that at http://jsfiddle.net/Rdx6f/, but the onreadystatechange event seems to only fire when readyState==1. (I'm using Firefox 4.0.1.) Oddly, when I alert the readyState upon onreadystatechange, things behave differently: http://jsfiddle.net/Rdx6f/1/.
A fix for this seeming bug would be useful -- e.g. for efficiently implementing XHR streaming.
- Cc jaubourg added
- Priority changed from undecided to low
- Component changed from unfiled to ajax
- Status changed from open to closed
- Resolution set to duplicate