In php:
header('content-type: application/json; charset=utf-8');
$res = array("success" => true, "status" =>array(),"path" =>array());
echo(json_encode($res));
I want to access path from above array.
In jQuery I am trying
on("success", function (Text) {
console.log("l path " + Text[0].path);
$.each(Text[0].path, function(i,k){
console.log(i+" "+k);
});
It is throwing an error:
Uncaught TypeError: Cannot read property 'path' of undefined'
response = JSON.parse(Text).var obj = JSON.parse(Text);and useobjin each. OR usedataType: 'json',in$.ajaxconfiguration options.JSONyou need to parse it first, otherwise it'll be a string.echo(json_encode($res));are you sure you are getting a valid json out of it?