SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON
This is a hackish and unorthodox way of parsing JSON, but if you still want to use JSON.parse()
from an AJAX call or simply on JSON that is already parsed and isn't a string, you can use JSON.stringify()
inside it:
var respons = JSON.parse(JSON.stringify(response));
Simply change
var respons = jQuery.parseJSON(response);
to
var respons = response;
Explanation:
If the configuration of your AJAX call is having dataType: json
you'll get a JavaScript object so it's no longer necessary to use JSON.parse().