I have a form with different input fields.So for very minute , the data entered by the user needs to be automatically stored in the database. Once the request is submitted , it will be directed to the struts file where the database interactions will be carried out .
What i have tried, I had set the timeout function to run every time the page is loaded
var timer;
$(document).ready(function() {
timer = setTimeout("autosave()", 60000);
});
And in the autosave function , i am trying to post the input data to the designated URL
jQuery('form').each(function() {
jQuery.ajax({
url: "http://localhost:7002/submitStudent.do?requestType=auto&autosave=true",
data: jQuery(this).serialize(),
type: 'POST',
success: function(data){
if(data && data == 'success') {
alert("data saved");
}else{
}
}
});
});
}
}
And once the request is sent to the struts , it will be processed based on the requesttype and the data will be submitted.
But in my case , data doesn't get saved.
Kindly share your suggestions on what i am doing wrong and any other ways to do it ?
Thanks for your valuable suggestion and time..
FYI , i am a beginner in Jquery and ajax technologies
JSFIDDLE : jsfiddle
requestType="auto"write this without double quotes..setTimeoutwill not call every minute .