I get a response from an ajax request and store request.responseText in a variable called requestData. requestData data contains a json object pass by php using json_encode().
See a couple of log I made bellow.
requestData : {"status":"ok","to":"","html":"<option value=\"Huberdeau\">Huberdeau<\/option><option value=\"Bo\u00eeleau\">Bo\u00eeleau<\/option><option value=\"Br\u00e9beuf\">Br\u00e9beuf<\/option><option value=\"Saint-R\u00e9mi-d'Amherst\">Saint-R\u00e9mi-d'Amherst<\/option><option value=\"Harrington\">Harrington<\/option>","message":"old"}
My probleme is that I can’t access the variable status. None of the following calls get the value properly.
requestData[status] : undefined
requestData.status : undefined
requestData['status'] : undefined
requestData[0]['status'] : undefined
And when I tried to dump my variable by a for log it treated it like string.
dump_var :
0:{
1:"
2:s
3:t
4:a
5:t
6:u
7:s
8:"
9::
I have found the trick in a comment on an other question. I post it here anyway cause it’s a bit difficult to notice in the original discussion.