$.ajax({
type: "post",
url: "/user_book/rentbook",
//contentType: "application/json;charset=utf-8",
**//dataType: "json",**
data:{"id":id,"user_id":user_id},
success: function (data) {
if(data == "success"){
refurbishIndex();
alert("借书成功");
}else if(data == "failed"){
alert("????");
}else{
alert("aaaaa");
}
},
error: function (data) {
alert("借书失败");
refurbishIndex();
}
});
只要把上面的dataType注释掉就好了
以为前端和后端一个传得JSON一个传得字符串,当然会报错了