415错误

60 阅读1分钟

出现415错误的解决方法:

  1. 前端看ajax请求的contentType是否与后端一致
  2. 看发送的数据格式是否正确。

下面是后端所需数据为json格式,contentType为application/json的ajax请求。


    $.ajax({
        url:'/xxxxxx',
        type:'POST',
        contentType: 'application/json; charset=UTF-8',
        dataType:'json',
        data:JSON.stringify(data),
        success: function (response) {
            console.log(response);
        }
    });