SyntaxError: JSON Parse error: Unrecognized token '<' SyntaxError: JSON Parse error: Unrecognized token '<' json json

SyntaxError: JSON Parse error: Unrecognized token '<'


It is probably because your request is returning an HTML instead of a JSON and when you try to parse it, the first char would be <, which is already invalid for a JSON string.

But it is really hard to be sure without you posting the HTTP response from server that you are trying to parse as a JSON or the code you are using to do it.


I had similar error. The error was because of the URL not being encoded. The steps to make it work are

In the server side, I used JSON.stringify and encode like

/login.html?userdetails="+encodeURIComponent(JSON.stringify(res))

and in the client side, the details was obtained by

JSON.parse(decodeURIComponent(params['userdetails']))