ajax 报400问题
小祝特烦恼 2017-01-18 04:17:01 请求代码如下
$(function() {
$("#submit").click(function() {
var id = "${info.id}";
var name = $('#name').val();
var code = $('#code').val();
var finishdate = $('#finishdate').val();
var description = $('#description').val();
$.ajax({
type : 'post',
async : false,
dataType : 'json',
data : {
id:id,
name:name,
code:code,
finishdate:finishdate,
description:description
},
url : "${pageContext.request.contextPath}/system/sc/addProject",
success : function(e) {
if (data.errorFlags) {
$('#name').html("");
$('#code').html("");
$('#finishdate').html("");
$('#description').html("");
$('#name').html(data.nameMessage);
$('#code').html(data.codeMessage);
}else {
alert("保存修改成功");
}
},
error : function(e) {
alert("保存修改失败");
}
});
});
});
后台代码
@RequestMapping("/addProject")
@ResponseBody
public ModelMap addProject(ProjectInfo info) throws Exception {
try {
ModelMap map = new ModelMap();
boolean flag = false;
map.put(Constant.errorFlags, flag);
return map;
} catch (Exception e) {
throw e;
}
}
错误
Failed to load resource: the server responded with a status of 400 (Bad Request)