I have an ajax call
$(\'#button1\').on(\'click\', function(e){
$.ajax({
url: url,
type: \'POST\',
async: true,
dataType: \'json\
As per the answer by Brennan,
$('#button1').on('click', function(e){
$('#button1').attr('disabled', 'disabled');
$.ajax({
url: url,
type: 'POST',
async: true,
dataType: 'json',
enctype: 'multipart/form-data',
cache: false,
success: function(data){
$('#button1').removeAttr('disabled');
},
error: function(){}
});
e.stopImmediatePropagation();
return false;
});
Here the button will be disabled and will be enabled on success