I'm looking for an alternative to window.stop() for IE. I have tried document.execCommand('Stop'), but it doesn't seem to work. I'm trying to cancel a XMLHttpRequest which is called from within a ASP user control i'm using. I can't use jQuery's .abort() since i do not set the request my self.
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to fix IE ClearType + jQuery opacity problem i
- Using :remote => true with hover event
- How to store image outside of the website's ro
- Is there a way to play audio on a mobile browser w
I assume control on the page uses jQuery.ajax and you know when you need to abort the request, under your criteria.
How about something like this?
Now you have a variable called xhr which holds the underlying xmlhttp object. You can call abort() on the object when you need to.
The draw back is that variable will be populated for each ajax request done by jQuery, and I would only include this script on that particular page, maybe even reset the ajax when you are done.
I haven't tried this, just an idea, as I have been mocking ajax calls all the time. Some might think that this approach is a little bit drastic!
Hope you find it useful.
I understand you don't set the request yourself, but do you have any kind of access to it, so that you can use the onreadystatechanged-event in javascript? If so, you can then determine whether or not you have to cancel the event.
If you have access to the object you can do it with the object's abort() and onreadystatechange event handler. Here is a working example I tweaked from w3schools
As you can see, the request text is not loaded because it gets aborted.