Reputation: 6449
How to convert JSON to plain text?
{"Days":["is not a number"]}
to Days is not a number.
Here is the code:
$('.best_in_place').bind("ajax:error", function(jqXHR,error, errorThrown) {
alert(error.responseText);
});
Upvotes: 0
Views: 10145
Reputation: 51711
Convert the response into JSON object and parse its key-value pair
var error = JSON.parse( error.responseText );
for( var name in error ) {
console.log( name + " " + error[ name ] ); // Days is not a number
}
Upvotes: 2
Reputation: 23580
As you're using jQuery, this might help:
var result = '';
$.each(error.responseText, function(key, value) {
result += key + ' ' + value;
});
This will also work and can easily be adjusted if the response holds multiple key-value-pairs.
Demo
Upvotes: 2