views:

44

answers:

2

If the user happens to have a delay in connecting to my site, the ajax hasnt timed out and the user decides to close the window. The ajax query will be terminated? Is there a way i can say still processing are you close you want to leave this page? (bonus if it will close once ajax was successful). How do i do this?

I am not sure if this is the same thing (maybe its built into firefox?) but when i closed this page it said

Are you sure you want to navigate away from this page?

You have started writing or editing a post.

Press OK to continue, or Cancel to stay on the current page.

I am positive i seen this other places. How do i make this appear when the user isnt submitting ajax and is in the middle of a post?

+4  A: 
rahul
+1  A: 

You can implement the onbeforeunload handler in js:

window.onbeforeunload = function() 
{
   if (showMessage)
   {
      return trye
   }
   else
   {
      return;
   }
}
PanJanek