When i post something with " to a php page, it gets escaped with \" ; . 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("&", "<", ">", """, "'");
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
2010-10-29 12:01:59
Thanx so much, exactly what I needed.
lolla
2010-10-29 12:23:46
@lolla you are welcome ;)
eldar
2010-10-29 12:29:31