开发者

Fix JS object replacing/encoding of strings?

I have an object with a value that has spaces in it, and it gets replaced wit开发者_开发技巧h an encoded string, like:

alldata["test"] will return "Long+name" or something like alldata["test"] will return "%BLong+name%B"

when it's set by using

alldata["test"] = "Long name" (or "[Long name]") via a series of code.

Am I missing something? I don't think using $.toEvalJSON is the right way to go because I haven't transformed the object into JSON. I'd rather not do a string.replace either because I'd have to capture every possible type of input that is encoded.

Thank you!


If your question is how to remove the encoding, you could always use

unescape(s)

See Escape and Unescape Functions


The issue is related to the fact that I failed to mention that the object was being assigned the string as a result of a .serialize() command. Hence a urldecode() will work perfectly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜