couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [47/50] jquery-couch commit: updated refs/heads/import-master to 66dbcbf
Date Tue, 01 Apr 2014 08:52:52 GMT
jquery.couch.js: db.changes().stop() should abort XMLHTTPRequest


Project: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/commit/620562c9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/tree/620562c9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/diff/620562c9

Branch: refs/heads/import-master
Commit: 620562c9865c52b45ada5de864583e1010b99534
Parents: b99d71e
Author: Fedor Indutny <fedor.indutny@gmail.com>
Authored: Tue Dec 10 17:29:16 2013 +0400
Committer: Alexander Shorin <kxepal@gmail.com>
Committed: Tue Dec 10 17:29:16 2013 +0400

----------------------------------------------------------------------
 jquery.couch.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/blob/620562c9/jquery.couch.js
----------------------------------------------------------------------
diff --git a/jquery.couch.js b/jquery.couch.js
index db4e8ef..1a4c3b7 100644
--- a/jquery.couch.js
+++ b/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){


Mime
View raw message