Just add id to the submit button, say #submitbutton .
and use the .prop() jQuery method to set the disabled attribute of the button.
$("#submitbutton").prop("disabled", true);
IMP: This will only work if you save the same page to ajax success , but if you reload the page, then you need to check php to see if this form was presented in this current $_SESSION .
So, inside your ajax php handler, you can perform the check as follows.
session_start(); if(!empty($_POST) && empty($_SESSION['post'])) { $_SESSION['post'] = true; ... do your code unset($_SESSION['post']); }else{
And in the html form, just add a hidden input with the name post and set the value to 1 or something that you consider necessary, so after submitting the form, the post will be installed inside the $_SESSION SuperGlobal Array array, and if the same form is submitted Twice by the same user, php will not accept it.
source share