Is there a way to detect when the user has clicked the stop button on any browser? I want to stop the script from running when the user decides to click the stop button when upl
Unfortunately the browser's stop button doesn't affect AJAX requests. If you want to cancel an AJAX request you can abort it like below:
var xhr = $.ajax(
url: "http://someurl.org",
success: function() { ... }
);
xhr.abort();
The button to trigger the abort will need to be in your HTML since the browser's stop button cannot abort the request. If the user went to another page the browser would stop listening though and this is essentially what happens when you call xhr.abort().