开发者

jquery htmldecode

how will i decode the string in the following line

  $("#" + result["DivName"]).append(result["Sav开发者_如何学CedValue"]);

ok i am using this scenario to save myself from the script attack. ok the thing is that if some one rights alert('hi') in the ckeditor . it saves in the database as it is but when i retrieves it i first encode it and then display it. but the thing is that encoded version is not displaying in the div which have a edit button by pressing it a ckeditor will open with the text in the div , yes i am using json.

the bottom line is that the scripts should not execute


If you want to insert it as HTML instead use decodeURIComponent() like this:

$("#" + result["DivName"]).append(decodeURIComponent(result["SavedValue"]));

Depending on how you're getting the data though, you may want a different approach...based on your syntax I'm not sure if you're dealing with JSON or something else...and if so how it's encoded.

If you are going though a JSON result, it should only be escaped coming back from the server if you intend to use it as HTML, in which case you wouldn't need to decode it on the client at all, just parsing it as JSON would give you the HTML string.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜