I have this ajax :
$.ajax({
url: '/PostComment/AddComment',
type: 'POST',
dataType: 'json',
cache: false,
data: { "PostId": PostId, "CommentText": CommentText },
success: function (data){
alert('Ok');
}
});
The problem is that when the CommentText variable contain any html tag the ajax call fail. I know this is a strange problem, but that is what happen.
Try sending encoded values to the server side:
commentText = encodeURIComponent(commentText);
On the server side, if you are using Java, then you can do:
String commentStr = URLDecoder.decode(request.getParameter("commentText"), "UTF-8");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.