Send a ajax when leave button is clicked onbeforeunload jquery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajax

Description

Send a ajax when leave button is clicked onbeforeunload jquery

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
      <script type="text/javascript">
window.onbeforeunload = callajax;//  w w  w.  j ava 2 s  .  c  om
function callajax() {
   /*Your ajax call code*/
   return "ajax response";//returning ajax response
}

      </script> 
   </head> 
   <body> 
      <a href="http://Yahoo.com">Yahoo</a>  
   </body>
</html>

Related Tutorials