Is there a reason why in the jQuery.ajax() method beforeSend() is
called AFTER the xhr.open() method?

The problem is that the readystatechange event for OPENED (1) is not
called in WebKit browsers(Safari, Chrome) when you bind a handler to
the xhr.onreadystatechanged after the connection has been opened
(xhr.open()). I need this for a long-polling connection (I want to do
several things when the connection is initiated).

I can't find a reason in the documentation for this (neither in the
jQuery source). Or is it an bad implementation of the WebKit browsers?

I've solved it for now by overriding the function for creating the xhr
object:
$.ajax({
     xhr: function() {
           var xhr = jQuery.ajaxSettings.xhr();
           xhr.onreadystatechange = function() {
                alert(xhr.readyState);
           };
     ...etc
});

Thanks,

Pieter

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to