call ajax function when user refreshes or leaves web page
<p>I need to call an ajax function when the user leaves a web page or refreshes a web page. So far I can call an ajax function when the user closes the page using javascript <code>window.onunload = my_ajax_function;</code> but I also need to call <code>my_ajax_function</code> when the page is refreshed or the user leaves the page to go to a different url.</p>
