I\'m submitting a form via AJAX using the code below:
$( \'form\' ).submit(function(e) {
$.ajax({
type: \'POST\',
url: ajax_url,
Just hide and show the submit button on submit.
$( 'form' ).submit(function(e) {
$('#my_button').hide();
$.ajax({
type: 'POST',
url: ajax_url,
dataType: 'json',
data: {
'action': 'my_action',
'str': $( 'form' ).serialize()
},
success: function( data ) {
// Do something here.
},
error: function( data ) {
// Do something here.
},
complete: function(){
$('#my_button').show();
}
});
return false;
});