Re: [jQuery] How to add event handler to XMLHttpRequest.onreadystatechange?
Turns out that xmlhttp.onreadystatechange is *write-only* in IE6, so attempting to read it was causing the code to barf. (Probably ok in other browsers but this particular work is in an IE6-only intranet) Is there any other way to set up a custom handler for the onreadystatechange event? Would there be any harm in overwriting JQuery's onreadystatechange handler with my own and going from there? Cheers, George Klaus Hartl wrote: George Adamson schrieb: Thanks for the code Klaus. Nice idea... When I tried this, the ajax call worked but the xhr.onreadystatechange is 'undefined' so I cannot do anything with it. (I got the samer error when trying to use a function in the 'beforeSend' ajax argument.) Does Jquery definitely return the XMLHTTP object? Or something else? Cheers, George It should be the XmlHttpRequest object. This tip worked for someone else if I remember correctly. What does your code look like? -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/Can-you-add-event-handler-to-XMLHttpRequest.onreadystatechange--tf3270003.html#a9150100 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How to add event handler to XMLHttpRequest.onreadystatechange?
George Adamson schrieb: Thanks for the code Klaus. Nice idea... When I tried this, the ajax call worked but the xhr.onreadystatechange is 'undefined' so I cannot do anything with it. (I got the samer error when trying to use a function in the 'beforeSend' ajax argument.) Does Jquery definitely return the XMLHTTP object? Or something else? Cheers, George It should be the XmlHttpRequest object. This tip worked for someone else if I remember correctly. What does your code look like? -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How to add event handler to XMLHttpRequest.onreadystatechange?
Thanks for the code Klaus. Nice idea... When I tried this, the ajax call worked but the xhr.onreadystatechange is 'undefined' so I cannot do anything with it. (I got the samer error when trying to use a function in the 'beforeSend' ajax argument.) Does Jquery definitely return the XMLHTTP object? Or something else? Cheers, George Klaus Hartl wrote: 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 discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/Can-you-add-event-handler-to-XMLHttpRequest.onreadystatechange--tf3270003.html#a9107770 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] How to add event handler to XMLHttpRequest.onreadystatechange?
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 -- View this message in context: http://www.nabble.com/How-to-add-event-handler-to-XMLHttpRequest.onreadystatechange--tf3270003.html#a9091489 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How to add event handler to XMLHttpRequest.onreadystatechange?
George, Have you tried looking the the timeout param? Not sure if it does what I think it does. -- Benjamin Sterling http://www.KenzoMedia.com http://www.KenzoHosting.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How to add event handler to XMLHttpRequest.onreadystatechange?
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 discuss@jquery.com http://jquery.com/discuss/