Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit f5be208

Browse files
committed
Correct issue #426 (Get "Not found" when an external request is cancelled because a new one is sent) by adding a flag to know if a current http request is still running
1 parent 8b3a2cf commit f5be208

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

angucomplete-alt.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
var responseFormatter;
7474
var validState = null;
7575
var httpCanceller = null;
76+
var httpCallInProgress = false;
7677
var dd = elem[0].querySelector('.angucomplete-dropdown');
7778
var isScrollOn = false;
7879
var mousedownOn = null;
@@ -440,7 +441,7 @@
440441
}
441442

442443
function httpErrorCallback(errorRes, status, headers, config) {
443-
scope.searching = false;
444+
scope.searching = httpCallInProgress;
444445

445446
// cancelled/aborted
446447
if (status === 0 || status === -1) { return; }
@@ -478,9 +479,11 @@
478479
cancelHttpRequest();
479480
httpCanceller = $q.defer();
480481
params.timeout = httpCanceller.promise;
482+
httpCallInProgress = true;
481483
$http.get(url, params)
482484
.success(httpSuccessCallbackGen(str))
483-
.error(httpErrorCallback);
485+
.error(httpErrorCallback)
486+
.finally(function(){httpCallInProgress=false;});
484487
}
485488

486489
function getRemoteResultsWithCustomHandler(str) {

0 commit comments

Comments
 (0)