が進行中のすべてのXHRは殺す進行中のすべてのXHRは
$( '#検索ボックス')。からkeyup(関数(){検索データをバインドする// VARを要求殺す要求します入力= $( '-入力を検索します。')のval();。
$.getJSON({ // get JSON data
url: 'example/query.php?keyword=' + input,
//pre-load
beforeSend: function() {
$(".search-lists").html("<span class='loading'><img src='_/images/loading.gif' /></span>");
},
success: function(data) {
if (input.length >= 3) { // limit keyword to >=3
var output = "<ul class='search-lists'>"; //output search data list
$.each(data, function(key, val) {
output += '<li>';
output += '<a>' + val.term + '</a>';
output += '</li>';
});
output += '</ul>';
$('.search-results').html(output);
console.log('load ajax');
} // end if
else {
console.log('kill ajax');
}
}
}); // JSON request
}); // data bind
'$ .getJSON(入力の長さは、<3であるか、XHRの結果はあなたがすべて殺すべきで空の配列の場合は、{' ... – Rayon
おかげでレーヨン、私はこの他のものをどのように修正すればよいの前に置き、あなたの状態を現在進行中のXHRリクエストとあなたが質問をしていなかった。 – webmansa
@rayonはあなたが最後の質問で私を助けることができるドロップダウンを閉じて「a.isEmptyObjectが」ではないと言います機能あなたはそれで私を助けることができるが、 'はconsole.log(typeof演算データ、データ)何@sesay – webmansa