[extensions-web] paginator: Cancel any outstanding requests before making a new one
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] paginator: Cancel any outstanding requests before making a new one
- Date: Fri, 9 Mar 2012 19:20:42 +0000 (UTC)
commit 49d6258f03d078da9b8753c0c0ff95f3c4a2bba4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Mar 7 16:32:51 2012 -0500
paginator: Cancel any outstanding requests before making a new one
This should prevent results from an older query overwriting a new one,
which is quite popular with live typing.
sweettooth/static/js/paginator.js | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/sweettooth/static/js/paginator.js b/sweettooth/static/js/paginator.js
index ef920db..af3fdbf 100644
--- a/sweettooth/static/js/paginator.js
+++ b/sweettooth/static/js/paginator.js
@@ -20,6 +20,8 @@ define(['jquery', 'hashparamutils',
var $beforePaginator = null;
var $afterPaginator = null;
+ var currentRequest = null;
+
function loadPage() {
$elem.addClass('loading');
$loadingPageContent.prependTo($elem);
@@ -30,7 +32,10 @@ define(['jquery', 'hashparamutils',
else
hashCopy = hashParams;
- $.ajax({
+ if (currentRequest !== null)
+ currentRequest.abort();
+
+ currentRequest = $.ajax({
url: url,
dataType: 'json',
data: hashCopy,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]