Skip to content

Commit 2a0cc76

Browse files
committed
Remove ajax out-of-order dropping code, handled in updateResults now.
1 parent 1eb461a commit 2a0cc76

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

select2.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ the specific language governing permissions and limitations under the Apache Lic
392392
*/
393393
function ajax(options) {
394394
var timeout, // current scheduled but not yet executed request
395-
requestSequence = 0, // sequence used to drop out-of-order responses
396395
handler = null,
397396
quietMillis = options.quietMillis || 100,
398397
ajaxUrl = options.url,
@@ -401,9 +400,7 @@ the specific language governing permissions and limitations under the Apache Lic
401400
return function (query) {
402401
window.clearTimeout(timeout);
403402
timeout = window.setTimeout(function () {
404-
requestSequence += 1; // increment the sequence
405-
var requestNumber = requestSequence, // this request's sequence number
406-
data = options.data, // ajax data function
403+
var data = options.data, // ajax data function
407404
url = ajaxUrl, // ajax url string or function
408405
transport = options.transport || $.fn.select2.ajaxDefaults.transport,
409406
// deprecated - to be removed in 4.0 - use params instead
@@ -433,9 +430,6 @@ the specific language governing permissions and limitations under the Apache Lic
433430
dataType: options.dataType,
434431
data: data,
435432
success: function (data) {
436-
if (requestNumber < requestSequence) {
437-
return;
438-
}
439433
// TODO - replace query.page with query so users have access to term, page, etc.
440434
var results = options.results(data, query.page);
441435
query.callback(results);
@@ -1511,6 +1505,7 @@ the specific language governing permissions and limitations under the Apache Lic
15111505
input,
15121506
term = search.val(),
15131507
lastTerm = $.data(this.container, "select2-last-term"),
1508+
// sequence number used to drop out-of-order responses
15141509
queryNumber;
15151510

15161511
// prevent duplicate queries against the same term

0 commit comments

Comments
 (0)