var title = $('#title').val();
var picture = $('#picture').val();
var content = $(".nicEdit-main").html();
var id = $("#id").val();
var data = 'title=' + title + '&content=' + content + '&id=' + id + '&istop=' + istop;
if(picture != ''){
data += '&picture=' + picture;
}
var url = "request->baseUrl;?>/system/ajaxeditnn";
$.ajax({
url: url,
type: "post",
data: data,
async:false,
success: function (data) {
var jsonObj = eval('('+data+')');
if(jsonObj.code == '200'){
alert('修改成功');
window.location.href="request->baseUrl;?>/system/bulletin";
}else{
alert(jsonObj.msg);
}
},
error: function (data) {
alert('错误');
}
});
这里的核心是content或者其他任何变量遇到了& 符号,就会截断内容,出错
所以提交之前先强制替换
content = content.replace(/&/g,"{@and@}");
然后我们在服务端再替换回去。
$info = $_REQUEST;
$info['content'] = str_replace("{@and@}","&",$info['content']);