Reset form and clear cache after submit

Most cache cache values ​​are, therefore, when the user goes to another page and then clicks the back button, there is no need to start over.

With the jquery form plugin, this also happens after the form is submitted successfully.

The following scenario:

  • User Submits Form

  • it is shown that the transfer was successful and the form is cleared.

  • user goes to another page

  • user clicks the back button

  • the page returns to the state before the form is submitted.

Calling resetForm () after submitting returns only the initial values ​​of the form, but does not solve the cache problem.

$(document).ready(function(){
    $('form').ajaxForm({
        success: function(responseText, statusText){
            displayMessage('form successful');
            $('form').resetForm();
        }
    });
});

Calling resetForm () when loading a page solves the cache problem, but when navigating through pages it breaks the expected behavior of the browser:

$(document).ready(function(){
    $('form').ajaxForm().resetForm();
});

?

+3
1

JQuery, ,

autocomplete='off'

,

, , . , - , .

+2

Source: https://habr.com/ru/post/1725271/


All Articles