Let's say I have an input like this
<input type="text" id="userhere">
What I want to do is to fire Ajax request when user finishes typing and is inactive for 1.5 sec. This is what I have tried to do, but it seems to fire every time the user inputs data every time, I want when the user finishes typing, then the data fires Ajax request only once not every time the user is typing.
<input type="text" id="userhere" oninput="autoSave(this)">
//and oninput is not cross browser effiecient
function autoSave(e){
setTimeout(function(){
var getsizes_response = $(e).attr("id");
var getsave_response_quantity = $("#"+getsizes_response).val();
$.ajax({
type: "POST",
url: "functions.php",
data: {getsizes_response: getsizes_response, getsave_response_quantity: getsave_response_quantity,},
cache: false,
timeout: 5000,
success: function(r){
$("#ajax_responses_get_positioner").show();
$("#ajax_responses_get_positioner").html(r);
}
});
}, 1500);
}
How do I fire the Ajax when user has finished typing?