I have the following code as aprt of my .ajax section
success: function (data) { alert("success"); }, error: function(xhr, ajaxOptions, thrownError) { alert(xhr.status); } The first alert never runs, however the data is submitted correctly using the below:
data: JSON.stringify({ "solution": JSON.stringify(data) }), // Data is HTML In fact, the second alert comes back with a status of 200 and everything through Google Chrome console looks fine.
Any idea? Full code:
var request = jQuery.ajax({ url: "/answers/"+content_id, type: "POST", data: JSON.stringify({ "solution": data }), dataType: "json", headers: { Authorization: 'Basic XXX', 'X-HTTP-Method-Override': 'PATCH', 'Content-Type': 'application/json' }, success: function (data) { alert("success"); }, error: function(xhr, ajaxOptions, thrownError) { alert(xhr.status); } });
error, the second of which is actuallytextStatusaccording to the documentation. It might be a "timeout", "parseerror" or other built-in error.