ajax - Javascript: alternative to encodeURIComponent? -
i have div i'm using in wysiwyg editor, , when user done writing gets submitted using ajax post request. i've been running problem: anytime text contains "&" character cut off after it. spent way time looking @ server-side code, issue turned out on client side (the whole url encoding thing). looked how fix on javascript side, , came "encodeuricomponent". based on pages read (links below), best way url encoding (escape deprecated , encodeuri doesn't encode characters.
when supposed use escape instead of encodeuri / encodeuricomponent? should use encodeuri or encodeuricomponent encoding urls?
but encodeuricomponent isn't working. here's how used it:
var wysiwyg = encodeuricomponent(document.getelementbyid("wysiwyg").innerhtml);
the contents of div submitted (so know it's not ajax call), doesn't fix "&" characters, , haven't been able find alternatives on google or so. i've got few shots in dark potentially going on, that's (no research, general guesses based on experience): - maybe kind of cross-browser wonkiness (not supported in firefox or stupid that)? - other parameter haven't found documentation (maybe encoding types utf-8 or whatever)? - undocumented gotcha using innerhtml?
so i'm grasping @ straws here. there known bugs encodeuricomponent? there alternatives available (apart doing ton of string replace work - btw i'm considering if can't work)? workarounds, links, suggestions or clues appreciated. thanks.
Comments
Post a Comment