I'm sending ajax calls on my web application and I want to show message or trigger onbeforeunload if there are still ajax call that is not yet finished when they leave the page.
onbeforeunload
So far, what I'm doing is I declared a global variable to count the running ajax calls - before sending ajax call I increment the counter and once ajax call is finished I decrement. I need to trigger the onbeforeunload when the counter is more than 0 when they leave page, I don't know if it's possible?
The lowest browser version I'm supporting is Firefox 45.0.2 Javascript only please.
2.1m questions
2.1m answers
60 comments
57.0k users