帮助了 AmazingCounters.com 位小伙伴

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("出错了,请重试!");
            }
    });
}

 

posted on 2018-08-13 14:45  云的旋律  阅读(612)  评论(0编辑  收藏  举报

导航

前端攻城狮分享群