I want to submit the form data to the database, 2 seconds after the user has entered the data in the form
I am using ajax function to accomplish this.but form gets submitted when a press a single key
$('#eid').bind('input propertychange', function() {
$.ajax({
method: "POST",
url: "intime2.php",
data: { content: $("#eid").val() }
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
});
When I enter the employee ID=12 in the form. I expect the result to be stored in database as 12 but the result stored is 1. before pressing 2 the data is submitted. I also want the form to be refreshed automatically for every consecutive submissions.
My goal: employees should enter their employee id(I am going to take inout from card reader, but for now I like to use timeout function) after entering the form should auto submit without them pressing the submit button then the form should refresh and next employee should enter his employee ID
Use debounce function to submit your form data to server
References: Debounce function in jQuery https://davidwalsh.name/javascript-debounce-function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.