Prevent too many requests in ajax call
by Mohan[ Edit ] 2014-01-17 19:01:03
Prevent too many requests in ajax call | jquery
To prevent too may request on ajax call ,use setInterval for ajax function. It will prevent the requests to server
var setinterval;
$(".dic_searchtxt").keyup(function(event){
var keyword=$("#id").val();
if(keyword!="")
{
setinterval=setInterval(ajaxcall,400);
}
});
function ajaxcall()
{
clearInterval(setinterval);
var keyword=$("#id").val();
$.ajax({
type: "GET",
url: "localhost/autosuggest.php",
data: "searchword="+keyword,
success: function(msg){
if(msg != 0)
{
alert("success");
}
else
{
alert("Error msg");
}
}
});
}
Guna
nice...
0
0
Add Reply