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

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -