There is a registration form that uses the AJAX submission how to prevent users from repeating the form, that is, after the user submits one after another for some other reason has not returned the results before the user submits the form again causes duplicate data to ask you what good way to solve
Reply to discussion (solution)
Take a look at the following code:
Namespace{flags:{}}namespace.flags.submit=true;document.getelementbyid (' btn '). AddEventListener (' click ', FormSub ); function formsub () { if (namespace.flags.submit) { namespace.flags.submit = false; $.post (' addr ', {params: '},function (data) { if (data = = ' OK ') { alert (OK); Namespace.flags.submit = True;}} );} }
Take a look at the following code:
Namespace{flags:{}}namespace.flags.submit=true;document.getelementbyid (' btn '). AddEventListener (' click ', FormSub ); function formsub () { if (namespace.flags.submit) { namespace.flags.submit = false; $.post (' addr ', {params: '},function (data) { if (data = = ' OK ') { alert (OK); Namespace.flags.submit = True;}} );} }
The main idea is to set a flag variable, this flag variable control can be submitted, the program does not write the whole, their own perfect
Show a rotating chrysanthemum bar
Then set up a send switch
Thank you for all your good ideas.
When the user clicks the button, the button is set to not be used.
Support for the 3 floor answer
Thank you for your enthusiastic reply.