In my Javascript and PHP, I've manage to do an .ajax call to get an array. However when I want to display the display the values of each object I'm unable to do so.
PHP:
$request = '{"request_id":' .$requestId. ', "reqName":"' .$requestName. '", "reqSubject":' .json_encode($requestSubjects). '}';
array_push($requestArray, $request);
echo json_encode($requestArray);
So when I console.log(data) it looks like this:
["{"request_id":13, "reqName":"Rin", "reqSubject":["English","A Math"]}", "{"request_id":14, "reqName":"Rin", "reqSubject":["English","E Math"]}"]
When I console.log(data[0]), I'm able to get the first object:
{"request_id":13, "reqName":"Rin", "reqSubject":["English","A Math"]}
However when I want to get the values of the object like so, console.log(data[0].request_id), it returns an undefined.
Would highly appreciate if someone could tell me what's wrong with my codes. Thank you.
data[0]["request_id"]