简体   繁体   中英

Allow user to cancel upload javascript, xmlhttp request

I have an xmlhttprequest that is posting to a webservice and is linked to the user uploading a potentially large file and I would like to be able to cancel the request based on user input. I see that the xmlhttprequest object has an abort function but as far as I can tell by watching the network tab in chrome, calling that does not actually stop sending data and free up the users bandwidth, it only affects the events

i would use jquery here:

var xhr = $.ajax({
type: "POST",
url: "x.php",
success: function(msg){
}
});

//kill the request
xhr.abort()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM