如何更改角度中的[‘Content-Type’]

前端之家收集整理的这篇文章主要介绍了如何更改角度中的[‘Content-Type’]前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想改变角度[‘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';
 });

事件是

$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);


        });
};

不过,

Parametersapplication/x-www-form-urlencoded
{"admin_name":"dd"}

我想要的是

Parametersapplication/x-www-form-urlencoded
 admin_name dd

那我该怎么办?

尝试:
var serializedData = $.param({admin_name:user.u_name,admin_password:user.cert});

$http({
    method: 'POST',url: 'http://172.22.71.107:8888/ajax/login',data: serializedData,headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }}).then(function(result) {
           console.log(result);
       },function(error) {
           console.log(error);
       });
原文链接:https://www.f2er.com/angularjs/143169.html

猜你在找的Angularjs相关文章