diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2013-12-10 17:29:16 +0400 |
---|---|---|
committer | Alexander Shorin <kxepal@apache.org> | 2013-12-10 17:29:16 +0400 |
commit | 9eb262979aa053f7d4b40bc39365a022ee0a52b6 (patch) | |
tree | 5fe83b17a217c96ffcc247b3a042188cadb94149 | |
parent | 6c71f2c22891ecb80225d779a810f3dc14fb72e7 (diff) | |
download | couchdb-9eb262979aa053f7d4b40bc39365a022ee0a52b6.tar.gz |
jquery.couch.js: db.changes().stop() should abort XMLHTTPRequest
-rw-r--r-- | share/www/script/jquery.couch.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js index db4e8efdc..1a4c3b7e7 100644 --- a/share/www/script/jquery.couch.js +++ b/share/www/script/jquery.couch.js @@ -412,6 +412,7 @@ // set up the promise object within a closure for this handler var timeout = 100, db = this, active = true, listeners = [], + xhr = null, promise = /** @lends $.couch.db.changes */ { /** * Add a listener callback @@ -428,6 +429,9 @@ */ stop : function() { active = false; + if (xhr){ + xhr.abort(); + } } }; // call each listener when there is a change @@ -458,7 +462,7 @@ feed : "longpoll", since : since }); - ajax( + xhr = ajax( {url: db.uri + "_changes"+encodeOptions(opts)}, options, "Error connecting to "+db.uri+"/_changes." @@ -976,7 +980,7 @@ ajaxOptions = $.extend(defaultAjaxOpts, ajaxOptions); errorMessage = errorMessage || "Unknown error"; timeStart = (new Date()).getTime(); - $.ajax($.extend($.extend({ + return $.ajax($.extend($.extend({ type: "GET", dataType: "json", cache : maybeUseCache(), beforeSend: function(xhr){ if(ajaxOptions && ajaxOptions.headers){ |