I had a problem when the data object passed to my full () callback function is not a json object, but rather a [Object Object]. I see a json response line in the data.responseText file.
Here is my jQuery.ajax request:
$.ajax({ url: 'api.php', dataType: 'json', data: { command: "GetBlacklist" }, type: 'POST', error: function(jqXHR, textStatus, errorThrown) { messageDiv.append("Error: " + errorThrown + "<br />"); }, complete: function(json) { $('.blacklist textarea').text(json.message); messageDiv.append("Blacklist loaded."); } });
And here is the answer that is sent:
{"message":"success","result":0}
It evaluates the valid JSON and I am posting the correct json header headers on the server. Itβs worth it!
source share