[Pkg-javascript-commits] [sockjs-client] 135/434: Make sure xhr is always aborted, even if user leaves the page.
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch master
in repository sockjs-client.
commit 762588078004638fa7b4c7a6c07603d052568875
Author: Marek Majkowski <majek04 at gmail.com>
Date: Wed Sep 7 15:17:15 2011 +0100
Make sure xhr is always aborted, even if user leaves the page.
---
lib/utils.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/utils.js b/lib/utils.js
index d9bc5be..db2f976 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -170,10 +170,11 @@ utils.createXHR = function(method, url, payload, callback) {
xhr.onreadystatechange = function(){};
}
// Explorer tends to keep connection open, even after the
- // tab is closed: http://bugs.jquery.com/ticket/5280
+ // tab gets closed: http://bugs.jquery.com/ticket/5280
try {
xhr.abort();
} catch(e) {};
+ utils.detachEvent('unload', cleanup);
}
callback = xhr = null;
};
@@ -187,6 +188,7 @@ utils.createXHR = function(method, url, payload, callback) {
}
};
xhr.send(payload);
+ utils.attachEvent('unload', cleanup);
return function (abort_reason) {
if (callback) {
callback(xhr, null, abort_reason);
@@ -218,6 +220,7 @@ utils.createIframe = function (iframe_url, error_callback) {
iframe.parentNode.removeChild(iframe);
iframe.src = "about:blank";
iframe = null;
+ utils.detachEvent('unload', cleanup);
}
};
var onerror = function(r) {
@@ -238,6 +241,7 @@ utils.createIframe = function (iframe_url, error_callback) {
};
_document.body.appendChild(iframe);
tref = setTimeout(function(){onerror('timeout');}, 5000);
+ utils.attachEvent('unload', cleanup);
return {
iframe: iframe,
cleanup: cleanup,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list