I am unable to access json data as it always fails and gives error as SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data search.php outputs t
Solution for your problem is JSON.stringify
You need to convert your data output into string i.e.,
var yourDataStr = JSON.stringify(yourdata)
and then validate your data with
JSON.parse(yourDataStr)
Then you can get your result. To validate, you can pass your data in below function :-
function validateJSON(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}