unsupported media type 415
jquery ajax请求报错解决方案:
两点:
data: JSON.stringify(obj),
contentType:"application/json",
完整post请求:
//post ajax
function getFodderList1() {
let token = getToken();
$.ajax({
type: 'POST',
url: host + 'api/collect/imgAdd',
headers: {
'token': token
},
data: JSON.stringify(obj),
dataType: 'json',
contentType:"application/json",
success: function (data) {
if (data && data.success) {
$.toast('取消成功');
$("#img_"+id).attr("src", '../res/image/sc.png');
} else {
$.alert(data.msg);
}
},
error: function () {
$.alert("出错了,请重试!");
}
});
}