Skip to content

Commit 404539e

Browse files
committed
Aborts the ajax call when a new is coming up
1 parent 011770a commit 404539e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

select2.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ See the License for the specific language governing permissions and limitations
212212
function ajax(options) {
213213
var timeout, // current scheduled but not yet executed request
214214
requestSequence = 0, // sequence used to drop out-of-order responses
215+
handler = null,
215216
quietMillis = options.quietMillis || 100;
216217

217218
return function (query) {
@@ -224,7 +225,10 @@ See the License for the specific language governing permissions and limitations
224225

225226
data = data.call(this, query.term, query.page);
226227

227-
transport.call(null, {
228+
if( null !== handler){
229+
handler.abort();
230+
}
231+
handler = transport.call(null, {
228232
url: options.url,
229233
dataType: options.dataType,
230234
data: data,

0 commit comments

Comments
 (0)