JQuery AJAX and Unload()

JQuery AJAX and Unload()

Hi guys,

I am trying to lock a page on my DB when a user enters the page this script is on and unlock it when they leave.

It works fin in IE and FF but CHROME refuses to work properly. It locks the page but never unlocks it. Is there an issue with the Ajax object and onunload events?

  1.     <script type="text/javascript">
  2.         function UnlockPage() {
  3.             $.ajax({
  4.                 type: "POST",
  5.                 url: "/services/PageManagerLock.asmx/Unlock",
  6.                 data: "{'id': '<%= PageId %>'}",
  7.                 contentType: "application/json; charset=utf-8",
  8.                 dataType: "json"
  9.             });
  10.             alert("unlocked");
  11.         }
  12.         function LockPage() {
  13.             $.ajax({
  14.                 type: "POST",
  15.                 url: "/services/PageManagerLock.asmx/Lock",
  16.                 data: "{'id': '<%= PageId %>'}",
  17.                 contentType: "application/json; charset=utf-8",
  18.                 dataType: "json"
  19.             });
  20.         }
  21.         $(window).unload(UnlockPage);
  22.         AddOnLoadEventHandler(LockPage);

  23.     </script>