I’m currently adding data into db table via Ajax like this: When user pushes button with id #submit_btn it fires following function and posts data. The code of function looks like this.
$("#submit_btn").click(function () {
$("#add_form").submit(function (e) {
e.preventDefault();
dataString = $("#add_form").serialize();
$.ajax({
type: "POST",
url: "processor/dbadd.php",
data: dataString,
dataType: "json",
success: function (result, status, xResponse) {
//do something if ajax call is success
var message = result.msg;
var err = result.err;
if (message != null) {
$.notifyBar({ cls: "success", html: message });
}
if (err != null) {
$.notifyBar({ cls: "error", html:err});
}
},
error: function (e) {
//ajax call failed
alert(e);
}
});
});
Is there anyway to modify this code for automatic submission in every 2-3 seconds? (autosave)
Pleas try this code
/// NEW ANSWER
///THIRD ANSWER