Answer the question
In order to leave comments, you need to log in
Why can't JSON.parse take a string into a json object?
There is an ajax request:
And there is an error in the javascript console:
If I replace the "[" and "]" characters with "{" and "}" - I will have exactly the same error.
The string on the backend is generated using json_encode()
Why can't JSON.parse take the string into a json object, what am I doing wrong?
Answer the question
In order to leave comments, you need to log in
The server gives you the left data, instead of an array. You return not only an array, but also a string(92) ... . Fix your backend and only return JSON without extra lines.
You only need to return an array (i.e. not escaped JSON).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question