diff lib/js/urweb.js @ 1763:22858505bb2d

Allow RPC and run it synchronously in onunload event.
author Vladimir Shabanov <vshabanoff@gmail.com>
date Wed, 16 May 2012 22:46:35 +0400
parents e9587120831a
children 25824a0e8bf1
line wrap: on
line diff
--- a/lib/js/urweb.js	Sun May 13 17:41:21 2012 -0400
+++ b/lib/js/urweb.js	Wed May 16 22:46:35 2012 +0400
@@ -1184,17 +1184,12 @@
 var unloading = false, inFlight = null;
 
 function unload() {
-    unloading = true;
-
     for (; inFlight; inFlight = inFlight.next) {
         inFlight.data.abort();
     }
 }
 
 function requestUri(xhr, uri, needsSig, isRpc) {
-    if (unloading)
-        return;
-
     var extraData = null;
 
     if (isRpc && uri.length > 2000) {
@@ -1202,7 +1197,7 @@
         uri = uri.substring(0, 2000);
     }
 
-    xhr.open("POST", uri, true);
+    xhr.open("POST", uri, !unloading);
     xhr.setRequestHeader("Content-type", "text/plain");
     try {
         xhr.setRequestHeader("Content-length", "0");