var descValue = $('#descEditArea').val();
descValue = descValue.replace(/ /g, '<br/>');
var url = "/network/KpiDescServlet";
$.ajax({
url:url,
type:"post",
data:{rm:Math.random(),kpiId:"<%=kpiId%>",kpiType:"<%=kpiType%>",kpiDesc:descValue},
dataType:"json",
success:function(data){
alert("修改成功");
$("#desc").html(descValue);
cancle();
},
error:function(){
alert("修改失败");
cancle();
}
});
后来查找资料才发现,后台返回处设置的为ContentType"text/xml",而前台要求的是json,后台返回的不是一个正确的json,所以报错,修改方法为把前台的dataType修改为text
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = null;
out = response.getWriter();
out.println(result);