+2 votes
ago by
there is an object
{readyState: 4, responseText: "{"companies-phone":["Phone must be an integer."]}", responseJSON: Object, status: 200, statusText: "OK"}


Need to get it - Phone must be an integer.

While name companies-phone is unknown, but he is always the only one in the responseText.

Already the smoke from the ears. Tried everything, for example:
for (var key in textStatus.responseJSON) {
var val = textStatus.responseJSON[key];
}
get ["Phone must be an integer."], but how to get rid of these parentheses and quotation marks?

2 Answers

0 votes
ago by
 
Best answer
{"companies-phone":["Phone must be an integer."]}

So the field itself in the array, so the array.
Something like this:
for (var key in textStatus.responseJSON) {
var val = textStatus.responseJSON[key][0];
}
0 votes
ago by
Actually why the square brackets in JSON?
...