javascript - AJAX Unload not firing -


i need run process when user exists or leaves page. have following code received question posted:

 <script> var unloaded = false;  $(window).on('beforeunload', unload); $(window).on('unload', unload);  function unload() {      if (!unloaded) {           $.ajax({             type: 'post',             async: false,             url: '/function/left/@viewbag.id',             success: function () {                 unloaded = true;                 $('body').css('cursor', 'default');             },             timeout: 5000         });     } } 

the problem /function/left event never fired. wrong?


Comments

Popular posts from this blog

Prolog - Listing -

orchardcms - change base url in local copy in Orchard CMS -

linear regression - Trying to get confidence/prediction intervals with `predict.lm` in R, but I keep getting an error regarding my dichotomous variable -