how to change post['Content-Type'] in angularjs
angularjs
Solution
Try like:
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);
});
Problem
i want to change post['Content-Type'] in angularjs so i use ``` 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'; }); ``` and the event is ``` $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); }); }; ``` however the rusult is ``` Parametersapplication/x-www-form-urlencoded {"admin_name":"dd"} ``` what i want is ``` Parametersapplication/x-www-form-urlencoded admin_name dd ``` so what i should do?