I'm using an Ajax call to make a POST request, and a call is subsequently made to an API. The result is then returned. I was originally using the success callback which was firing, but then for some reason it stopped working, and I read that it has been replaced with done, so I tried changing it. I don't know why, but now neither done nor success will fire.I updated the browser recently, so maybe that has something to do with it. I'm also running it within Wordpress. 200 is being returned in the network tab, with the status and message encoded as JSON. The jQuery version is 1.12.4. Although the Ajax call completes, there is nothing logged in console, and the dialog doesn't open. How can I get this to work?
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_object.ajax_url,
data: {
'action': $action,
'product_id': $product_id,
},
success: function(data) {
console.log(data.message);
$( "#dialog" ).text(data.message);
$( "#dialog" ).dialog( "option", "title", "API - " + data.status );
$( "#dialog" ).dialog("open");
}
});
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_object.ajax_url,
data: {
'action': $action,
'product_id': $product_id,
}
}).done(function(result) {
console.log(result.message);
$( "#dialog" ).text(result.message);
$( "#dialog" ).dialog( "option", "title", "API - " + result.status );
$( "#dialog" ).dialog("open");
});