小编XzA*_*lar的帖子

如何在angularjs中更改post ['Content-Type']

我想在angularjs中更改post ['Content-Type'],所以我使用

  app.config(function($locationProvider,$httpProvider) {
$locationProvider.html5Mode(false);
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;        charset=UTF-8';
 });
Run Code Online (Sandbox Code Playgroud)

事件是

     $http.post("http://172.22.71.107:8888/ajax/login",{admin_name:user.u_name,admin_password:user.cert})
        .success(function(arg_result){

            console.log(arg_result);


        });
};
Run Code Online (Sandbox Code Playgroud)

然而,结果是

Parametersapplication/x-www-form-urlencoded
{"admin_name":"dd"} 
Run Code Online (Sandbox Code Playgroud)

我想要的是什么

Parametersapplication/x-www-form-urlencoded
 admin_name dd
Run Code Online (Sandbox Code Playgroud)

那我该怎么办?

angularjs

16
推荐指数
3
解决办法
5万
查看次数

标签 统计

angularjs ×1