Skip to content
Snippets Groups Projects
Commit 42bfe425 authored by Kevin Abel's avatar Kevin Abel
Browse files

Allow a cancelled directoy request to abort the pending XHR

parent b78b5f23
No related branches found
No related tags found
No related merge requests found
...@@ -82,6 +82,9 @@ ...@@ -82,6 +82,9 @@
}; };
Directory.prototype.cancelSearch = function() { Directory.prototype.cancelSearch = function() {
this._searchCanceled = true; this._searchCanceled = true;
if (this._xhr) {
this._xhr.abort();
}
}; };
Directory.prototype.execute = function(q) { Directory.prototype.execute = function(q) {
var cacheData = this._cache.get(q), var cacheData = this._cache.get(q),
...@@ -92,7 +95,7 @@ ...@@ -92,7 +95,7 @@
if (cacheData) { if (cacheData) {
this._render(cacheData); this._render(cacheData);
} else { } else {
$.get(this._server + '/service.php?q=' + encodeURIComponent(q), function(data) { this._xhr = $.get(this._server + '/service.php?q=' + encodeURIComponent(q), function(data) {
self._cache.save(q, data); self._cache.save(q, data);
self._render(data); self._render(data);
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment