Javascript angularjs$http正在强制执行内容类型标头
我正在尝试发布一个表单,使用以下命令:Javascript angularjs$http正在强制执行内容类型标头,javascript,angularjs,http,Javascript,Angularjs,Http,我正在尝试发布一个表单,使用以下命令: $http({ url: authUrl, method: 'POST', data: params, headers: { 'Content-type': 'application/x-www-form-urlencoded', 'Accept':
$http({
url: authUrl,
method: 'POST',
data: params,
headers: {
'Content-type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
}
}).success($scope.getEmailData).error($scope.httpError);
但当我签入fiddler时,内容类型被发送为content-type:application/json;字符集=UTF-8应用程序/x-www-form-urlencoded
这是一个bug还是我遗漏了什么?请尝试使用
内容类型
而不是内容类型
作为密钥
此外,如果未定义params
,则可能会导致问题。尝试将数据设置为'
。即
$http({
url: authUrl,
method: 'POST',
data: params || '',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
}
}).success($scope.getEmailData).error($scope.httpError);