HTTP 请求头方式(application/x-www-form-urlencoded 或者application/json;charset=utf-8)

设置请求头 封装axios的时候,给它全局设置 application/x-www-form-urlencoded 或者application/json;charset=utf-8

axios.defaults.baseURL = 'https://www.172u.cn';
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

或者jQuery 中 $.ajax application/x-www-form-urlencoded 或者application/json;charset=utf-8

$.ajax({
   type: 'POST',
   contentType: 'application/json;charset=utf-8', // 发送的数据类型
   dataType: 'json',   // 接收的数据类型
   url: 'http://www.172u.cn',
   data: JSON.stringfy(formData),
   success: function (res) {
      console.log(res.data)
   }
}) 

此处评论已关闭