0

If I send an ajax request, and before the response was returned by the server the user closed the browser, what happens with the response?

For some reason I get it to the error callback, though I can't understand how, since the browser is closed.

beanyumas
  • 23
  • 1
  • See this [Link](http://stackoverflow.com/questions/8916690/what-happens-if-a-user-exits-browser-or-change-page-before-ajax-request-is-over) – Jayaram Dec 25 '13 at 15:22
  • Thanks @JayaramPai . But the link doesn't answer what happens to the response in the browser. just what happens to the request on the server. I do get a response, but how and what kind of response if the server didn't answer yet? – beanyumas Dec 25 '13 at 15:30
  • Your PC receives it but does not make it available for the browser. [Similar Question](http://stackoverflow.com/questions/13395389/what-happens-to-the-data-that-my-ajax-requested-if-the-browser-closed-and-there) – Jayaram Dec 25 '13 at 15:34
  • since javascript is only available in window,what you are suggesting makes no sense at all since window doesn't exist – charlietfl Dec 25 '13 at 15:38
  • @charlietfl - It didn't make sense to me as well, but in my error callback (and only in my error callback) I'm cleaning my local storage, so I can see if the error callback was called. – beanyumas Dec 25 '13 at 15:50
  • see [this](http://stackoverflow.com/q/8886099/492258) – asdf_enel_hak Dec 25 '13 at 15:54

1 Answers1

0

You might want to look at the abort progress event and the accompanying gory details. It is highly likely that the browser will fire the onreadystatechange handler with abort as the state. jQuery (or whichever library you are using) will assume that the request failed and fire the higher level error handler.

Salman A
  • 262,204
  • 82
  • 430
  • 521