Possible Duplicate:
JSON: why are forward slashes escaped?
I am passing values which contain "//"
from PHP to Javascript. However the values keep parsing "//"
as: "\/\/"
when I decode using json, no matter how I try to enclose or escape the strings... .
Here's the code I'm using:
PHP
foreach($varr as $vr)
{
array_push($legendarr, "%%.%% - ".$vr);
array_push($linkarr, "http://".$_SERVER['HTTP_HOST']."/getdata.php?criteria=".$vr);
}
JavaScript:
pie = r.piechart(320, 240, 100, , { legend: , legendpos: "west", href: });
The problem is that the variable linkarr
is displayed in the form:
http:\/\/localhost:8090\/getdata.php?criteria=......
Could anyone know why this is happening? How can I fix it?
Thanks.
Answer
A string "http:\/\/www.example.org"
will still be printed as "http://www.example.org"
in JavaScript.
The escaped slashes is, I believe, part of the JSON standard. But it shouldn't affect your JS code in any way.
Btw, the mysql_escape_string('//')
is completely out of context; HTML != database.
No comments:
Post a Comment