JSON.parse() is not converting my PHP string to a JavaScript object -


i have used json_encode() echo associative array php javascript through $.post method:

$.post("php/myfile.php", {}, function(data){     exercises = data;     //exercises = json.parse(data);   // console -> uncaught referenceerror: json not defined     alert(typeof exercises);          // alerts -> string     alert(exercises);                 // alerts -> {"1":"bench press","2":"squat","3":"deadlift"}     alert(json.stringify(exercises)); // console -> uncaught referenceerror: json not defined }); 

for reason can't convert string javascript associative array using json.parse().

what's issue?

you can pass json datatype ajax call jquery pass converted value

$.post("php/myfile.php", {}, function (exercises) {     alert(typeof exercises); // alerts -> string     alert(exercises); }, 'json'); 

in code problem case of json, should json.parse() not json.parse()


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -