【发布时间】:2015-08-16 03:54:29
【问题描述】:
谁能帮我找出为什么这段代码可以正常工作:
$.ajax({
type: "POST",
url: scope.serviceBase + "/api/Property/PostAsync",
contentType: "application/x-www-form-urlencoded",
processData: false,
data: data,
success: function (response) {
alert(response);
},
error: function (response) {
alert(response);
}
});
虽然完全相同的事情只是使用 Angularjs 失败了:
$http({
method: "POST",
url: scope.serviceBase + 'api/Property/PostAsync',
headers: {
'processData':false,
'Content-Type': "application/x-www-form-urlencoded"
},
data: data
}).success(function (response) {
alert(response);
}).error(function (response) {
alert(response);
});
仅供参考,我使用 AngularJs 格式时遇到的错误是 400 bad request。
【问题讨论】:
-
我认为 AngularJS 中不存在 ProcessData。如果 processData 的目的是将数据转换为 post 或 get,则称为 transfromRequest 和 transformResponse。这些不在标题内
标签: jquery angularjs post http-post bad-request