- $(window).bind('beforeunload', function() {
- $.post('/ajax', {
- email: "<?= $u->get('email') ?>",
- program: "<?= PROGRAM ?>",
- module: "<?= MODULE ?>",
- page: "<?= PAGE ?>"
- });
- });
BUT, I'd prefer not to use beforeunload as it doesn't seem to be supported everywhere. Using unload in .bind (or .unload itself) doesn't work. This is a shot in the dark, but would it work if I used $.ajax instead with async as false? My guess is it's closing before the request can go through.