Mercurial > urweb
changeset 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 | a6eab6820b37 |
children | e8c668e518fb |
files | lib/js/urweb.js src/c/urweb.c |
diffstat | 2 files changed, 3 insertions(+), 8 deletions(-) [+] |
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");
--- a/src/c/urweb.c Sun May 13 17:41:21 2012 -0400 +++ b/src/c/urweb.c Wed May 16 22:46:35 2012 +0400 @@ -1336,8 +1336,8 @@ if (ctx->script_header[0] == 0) return ""; else { - char *r = uw_malloc(ctx, 22 + strlen(s)); - sprintf(r, " onunload='unload();%s'", s); + char *r = uw_malloc(ctx, 37 + strlen(s)); + sprintf(r, " onunload='unloading=true;%s;unload()'", s); return r; } }