I have a php file that sends string to a js file using xmlhttp. The js file should convert the string to an object and start doing his thing on this object.
Well, the php file is printing this string:
$obj="{status:'ok',data:'{link:\"".$link."\",c:\"".$c."\",p:\"".$p."\"}'}";
echo $obj;
and the js file should get this:
{status:'ok',data:'{link:"http://test.com/test.html",c:"9",p:"1"}'}
While I'm trying to convert this string on the js file from string to an object, I'm getting a syntax error on ie8 (works fine in firefox and chrome).
Here is how I do it in the js file:
eval("var response=" + xmlhttp.responseText);
I tried to place the string manually in the js file and the eval worked, so I think the problem is with the apostrophes and quotation marks posted by the php file.
What do you think? does anyone knows a solution for this kind of problem?
Thanks in advance!
var response={status:'ok',data:'{link:"http://test.com/test.html",c:"9",p:"1"}'}'
– Avi Levin Dec 13 '11 at 4:42eval
? – Jordan Dec 13 '11 at 4:50