Most browsers cache form values, so when the user navigates to another page and then presses the back button doesn't have to start over again.
With the jquery form plugin this also happens after the form has been submitted successfully.
The following scenario:
user submits form
message is shown that submission was successful and form is cleared
user navigates to some other page
user presses the back button
page is restored to the state before the form was submitted.
Calling resetForm() after submit only brings back the initial form values but doesn't solve the cache issue.
$(document).ready(function(){
$('form').ajaxForm({
success: function(responseText, statusText){
displayMessage('form successful');
$('form').resetForm();
}
});
});
Calling resetForm() when the page is loaded solves the cache issue but breaks the expected browser behavior when navigating between pages:
$(document).ready(function(){
$('form').ajaxForm().resetForm();
});
Is there a way to clear the cache after a successful submit?