$.post on unload event

$.post on unload event

Hey guys, I can't seem to get this working. Here's the only thing that actually does work:

  1. $(window).bind('beforeunload', function() {

  2. $.post('/ajax', {
  3. email: "<?= $u->get('email') ?>",
  4. program: "<?= PROGRAM ?>",
  5. module: "<?= MODULE ?>",
  6. page: "<?= PAGE ?>"
  7. });

  8. });
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.