$.ajax({
type: "post",
dataType: "json",
url: "../exam/submit.do",
contentType: "application/json;charset=UTF-8",//指定消息请求类型
data: JSON.stringify(json),//将js对象转成json对象
success: function (data) {
if (data.error == 0) {
alert("交卷成功");
} else {
alert(data.error + " " + data.msg);
}
}
});
出错原因:缺少
contentType: "application/json;charset=UTF-8",
添加之后即可解决