我想改变角度[‘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); });