删除输入后请求继续发送并显示所有查询的结果。在所有输入为空后如何停止发送?
这是我的代码:
var typingTimer;
var doneTypingInterval = 3000; //time in ms, 5 second for example
$('#formsearch').find(':input').each(function(){
$(this).keyup(function(){
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
})
$('#formsearch').find(':input').each(function(){
$(this).keydown(function(){
clearTimeout(typingTimer);
});
})
//on keydown, clear the countdown
//user is "finished typing," do something
function doneTyping () {
var name = $('#fname').val();
var p = $('#persona').val();
var c = $('#comp').val();
$.get("?task=body&wtd=searchlead&fname="+name+"&comp="+c+"&per="+p,
function(data){
if(data != ""){
$('#result').html(data);
} else {
$('#result').html("No matching records");
}
});
}