A common problem with ajax requests is that your response comes in a string. And a json in text is not particularly useful.
There is a small trick to restore your json to its original glory: eval( “(“+jsonString+”)”);
There you go!
Thoughts about application development & technology management
A common problem with ajax requests is that your response comes in a string. And a json in text is not particularly useful.
There is a small trick to restore your json to its original glory: eval( “(“+jsonString+”)”);
There you go!
Comments are closed.
This is really not a great idea since eval is so dangerous to use that way. You should really offer better was to do it. JSON.parse in newer browsers. I usually use the easy to find parseJSON.js and then wrap the call to test for the JSON object before calling the non native method.
Very true! I did not have to use it from untrusted sources, I will add your recommendation