Web Service Not Running in onbeforeunload for reload

297 Views Asked by At

I have an onbeforeunload method that calls a web service method. It works great when I click on a link to another page, but when I reload the page, the onbeforeunload method runs and it processes the web service call on the client side as normal, but it never actually reaches the web service on the server side.

If I put an alert message after the call, then it works. So it appears that the page unloads so fast that the web service doesn't get called.

How can I make sure the web service gets called without the alert?

function pageUnload_ProcessLayout(sender, args){        
        webservice.removeHolder(Global.currUser.UserId, function(result){ });
        alert(2);
}

Thanks.

0

There are 0 best solutions below