You are specifying an invalid value for the dataType
setting. This causes the .fail
callback to get called (instead of the .done
callback), even though the jqXHR.status
is 200. The second parameter to the .fail
callback function (the "textStatus" parameter) will be "parsererror"
.
You should have:
contentType: "application/json; charset=UTF-8",
dataType: "json",
With the contentType
setting, you are specifying the content-type for the ajax request. When you set dataType
to "json"
, you are telling jQuery that the response will be JSON. That causes jQuery to automatically parse the response into an object (or array or null) before passing it as the data
parameter to the .done
callback function.