javascript - escape single quote in JKL.Parsexml -
i'm facing strange problem escaping single quote through xml parser:
var strcallurl = contextpath + "controller?formfilter=registration&selectedusertype="+usertype+"&emailid="+advisoremail;
strcallurl = strcallurl.replace(/'/g, "\'");
alert(strcallurl);
var objseamlessregload = new jkl.parsexml.text(strcallurl,'','post');
when hit last line, doesn't go forward because of singlequote inserted in email address(var advisoremail), without single quote in variable, works absolutely fine. possible escape single quote through jkl.parsexml.text()?
i have tried "\'" , tried escape(strcallurl), none of these seem work.
using escape
work, applying entire url, encode in url shouldn't encoded.
use on value only, , use encodeuricomponent
method instead (best practice: escape, or encodeuri / encodeuricomponent):
var strcallurl = contextpath + "controller?formfilter=registration&selectedusertype="+usertype+"&emailid="+encodeuricomponent(advisoremail); alert(strcallurl); var objseamlessregload = new jkl.parsexml.text(strcallurl,'','post');
Comments
Post a Comment