小编Dax*_*Dev的帖子

AngularJS 406不接受http post请求

我对用于表单的Post查询有问题.每次我尝试验证表单时都会出现"406不可接受"错误,而Object.data为空白.

var edit = function(form){
var token = window.localStorage.getItem('token');
$ionicLoading.show();
return $http({
       method  : 'POST',
       url     : API.url + '/user',
       headers : {Authorization : 'Bearer ' + token},
       transformRequest: function(data, headers){
            console.log(headers);
            headers = angular.extend({}, headers, {'Content-Type': 'application/json;charset=UTF-8'});
            console.log(headers);
            console.log(data);
            console.log(angular.toJson(data));
            return angular.toJson(data); // this will go in the body request
            },
           data    : form
   }).then(function(result) {
    console.dir(result.data);
},function errorCallback(response) {
      console.log(response);
 });
Run Code Online (Sandbox Code Playgroud)

};

我不明白为什么不接受..

json http http-post http-status-code-406 angularjs

2
推荐指数
1
解决办法
3854
查看次数

标签 统计

angularjs ×1

http ×1

http-post ×1

http-status-code-406 ×1

json ×1