1

hi all i am working with beforeunload jquery event but i am a bit confuse because i am in situation like if user click on leave the page button than i have to call ajax and delete the data i saved. if user click on stay on page button i wont send an ajax request than. but the problem is that i did'nt find any thing that can complete my problem in stack overflow as well as in Google. i have copied this snippet which is working perfectly

 $(window).bind('beforeunload', function() {
            return 'my pharse!';
    }); 

But what i want to do is:

$(window).bind('beforeunload', function() {
         if(click on leave the page button)
         {
            ajax({ url:'',method;'post' }); etc
         }
         else
         {
            do nothing;
         }
return 'my pharse ';            
    }); 
Vicky
  • 982
  • 2
  • 11
  • 28

0 Answers0