Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
jquery.couch.js: db.changes().stop() should abort XMLHTTPRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny authored and kxepal committed Dec 10, 2013
1 parent 493f700 commit 38b61af
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions script/jquery.couch.js
Expand Up @@ -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
Expand All @@ -428,6 +429,9 @@
*/
stop : function() {
active = false;
if (xhr){
xhr.abort();
}
}
};
// call each listener when there is a change
Expand Down Expand Up @@ -458,7 +462,7 @@
feed : "longpoll",
since : since
});
ajax(
xhr = ajax(
{url: db.uri + "_changes"+encodeOptions(opts)},
options,
"Error connecting to "+db.uri+"/_changes."
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit 38b61af

Please sign in to comment.