I have an ajax call
$(\'#button1\').on(\'click\', function(e){
$.ajax({
url: url,
type: \'POST\',
async: true,
dataType: \'json\
I was facing the same issue and it works when I set async: false.
Sample code will be like this
$('#button1').on('click', function(e){
$.ajax({
url: url,
type: 'POST',
async: false,
dataType: 'json',
enctype: 'multipart/form-data',
cache: false,
success: function(data){
},
error: function(){}
});
});