开发者

Getting rid of \&quot in js file

When i post something with " to a php page, it gets escaped with \&quot ; . To get rid of this in the php file, i've tried str_ireplace, htmlspecialchars_decode and stripslashes, nothing is working. Is there a way 开发者_Go百科i can strip it out after it's returned to the js file?


after you getting response from ajax request use this function to decode

function htmlspecialchars_decode(text)
{
   var replacements = Array("&", "<", ">", '"', "'");
   var chars = Array("&amp;", "&lt;", "&gt;", "&quot;", "'");
   for (var i=0; i<chars.length; i++)
   {
       var re = new RegExp(chars[i], "gi");
       if(re.test(text))
       {
           text = text.replace(re, replacements[i]);
       }
   }
   return text;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜