George Adamson schrieb:
> Hi folks,
>
> Anyone know if it is possible to add a custom event handler for the
> onreadystatechange events of JQuery AJAX calls?
>
> I'm accessing a url that is slow to complete but does add to its output as
> it progresses.
> It would be nice to be able to catch each new fragment to inform the user of
> progress.
>
> I've experimented with the 'beforeSend' ajax argument to fiddle with the
> XMLHttpRequest object's properties before making the ajax call but had no
> luck.
>
> Many thanks,
>
> George
$.ajax returns the XmlHttpRequest object, thus you can do:
var xhr = $.ajax({ ... });
xhr._cachedOnreadystatechange = xhr.onreadystatechange;
xhr.onreadystatechange = function() {
xhr._cachedOnreadystatechange();
// do something else
};
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/