Jquery 如何通过ajax停止和标记,但将其保留为文本
我有一个通过ajax提交的评论表单 下面是ajax代码Jquery 如何通过ajax停止和标记,但将其保留为文本,jquery,ajax,sanitization,Jquery,Ajax,Sanitization,我有一个通过ajax提交的评论表单 下面是ajax代码 $('#button').click(function(){ comment = $('#comment').val(); $.ajax({ type : 'POST', url : '/ajax/comment.php', data : 'comment='+comment, success : function(data) {
$('#button').click(function(){
comment = $('#comment').val();
$.ajax({
type : 'POST',
url : '/ajax/comment.php',
data : 'comment='+comment,
success : function(data) {
$('#comment_update').html(data);
}
});
});
问题是,如果有人评论像这样的“this comment&this comment”,那么,&会让帖子认为有一个额外的变量,从而将评论剪切为“this comment”,剩下的就留下。我应该在这里做些卫生处理吗?或者,如果“&”在字符串中,那么整个字符串如何处理。尝试使用json数据类型并相应地修改数据属性
dataType: "json",
data: {
comment: comment,
morestuff: morestuff
},
对不起,我没有提到这一点,我只是在这里的独角兽