0

Is there any event I could subscribe to if the submit of a form is aborted?

I.e.: On submitButton.click() I show a loading.gif next to it, so the user has some kind of feedback until the next page is loaded (in that special case, the request can take up to 10s). However, if the user presses escape or somehow else aborts the loading of the next page -> the gif is still visible. How to react to this event?

D.R.
  • 20,268
  • 21
  • 102
  • 205
  • are you doing an ajax call ? – Susheel Singh Apr 24 '14 at 17:42
  • 1
    An idea: send the form using an AJAX request, that way the user won't be able to simply abort and if he does you can use the `error` handler to catch a failed attempt to send the request, which also includes an abort. – iMoses Apr 24 '14 at 17:43
  • No, it is not an AJAX call. Unfortunately, I also cannot convert it to an AJAX call :-/ – D.R. Apr 24 '14 at 17:45
  • I'm sorry, but I believe this answer is still 100% accurate: http://stackoverflow.com/questions/1776447/detect-when-user-clicks-link-but-aborts – iMoses Apr 24 '14 at 17:50
  • 1
    Here's the way to detect the use of the escape key: http://stackoverflow.com/questions/3369593/how-to-detect-escape-key-press-with-javascript, but I concur that other types of stops cannot be detected. From a usability perspective, I wouldn't worry about it too much. If the user clicks the browser "Stop" button, they shouldn't expect the page to continue doing something intelligent. – George Cummins Apr 24 '14 at 17:53
  • What part of the submit takes 10 seconds? the sending? the processing of the request? the receiving of the request? If the sending is already done, the user can abort it all they want and the server will still finish the processing portion. – Kevin B Apr 24 '14 at 17:57

0 Answers0