blirette Posted April 30, 2010 Share Posted April 30, 2010 Hi all, I'm pretty new to using this JSON thing and would like to know why this isn't working. I'm trying to get via AJAX some infos that I'd like to be formatted in JSON so I can parse them easily. A PHP page is generating this string : {"lastName":"Hope","firstName":"Bob","email":"bobhope@hotmail.com"} I'm trying to retrieve it from another PHP page via this : var aInfos = xmlhttp.responseText; alert(aInfos.firstName); alert(aInfos.lastName); alert(aInfos.email); But it doesn't seems to work. It says "undefined". When I replace "xmlhttp.responseText" with "{"lastName":"Hope","firstName":"Bob","email":"bobhope@hotmail.com"}", it works. What am I missing? Thanks for your time and have a nice day! Quote Link to comment Share on other sites More sharing options...
blirette Posted April 30, 2010 Author Share Posted April 30, 2010 I love to solve things by myself! I had to eval() it. var JSONFile = xmlhttp.responseText; eval(JSONFile); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.