tags:

views:

18

answers:

1

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 i can strip it out after it's returned to the js file?

A: 

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;
}
eldar
Thanx so much, exactly what I needed.
lolla
@lolla you are welcome ;)
eldar