По моему опыту, это была вещь соглашения. Я не знаю ни о какой технической причине для использования интервала по Int32, но это:
я особенно люблю тот последний.:)
I believe you need to make the request synchronous instead (it's asynchronous by default) using the async : false
parameter.
Synchronous requests lock up the browser until they complete. If the request is asynchronous, the page just keeps on unloading. It's quick enough that the request never even has time to fire off.
Try calling it with async = false;
jQuery.ajax({url:"http://localhost:8888/test.php?", async:false})
I just tried it.
Maybe you'd have more success using the onbeforeunload
event instead?
$(window).bind('beforeunload', ...
Your function and Ajax call look fine, so my guess is that your browser window is closed before ajax call has time to go to the server and back. The ajax call might return something when the window is closing, try adding error function to your ajax call to see if that's the case:
error: function (xhr, textStatus) {
alert('Server error: '+ textStatus);
}