开发者

how can retrieve a string saved in the database correctly using a AJAX call?

This is the string saved in the database:

~`@#$%^&*()_+}{":?><,./;'[]=-|\"

But it returns as:

~`@#$%^&amp;*()_+}{&quot;:?&gt;&lt;,./;&#039;[]=-|\&quot;

This is my AJAX function:

function 开发者_如何学PythongetComment(timesheetId,activityId,date,employeeId){

var r = $.ajax({
        type: 'POST',
        // contentType: " charset=utf-8",
        url: linkToGetComment,
        data: "timesheetId="+timesheetId+"&activityId="+activityId+"&date="+date+"&employeeId="+employeeId,
        async: false,

        success: function(comment){
            cmnt= comment;

        }
    });
    return cmnt;
}


Try calling:

unescape(YOUR_STRING);

The special characters are being html encoded at some point, so you need to unencode them.

http://www.w3schools.com/jsref/jsref_unescape.asp


Before un-escaping any string, you should really make sure your text is coming from a safe source and is not based on any user input.

That said, the unescape() function should work for you:

cmnt= unescape(comment);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜