这对我很管用
// default post header
$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
// send login data
$http({
method: 'POST',
url: 'abc.php',
data: $.param({
email: "abc@gmail.com",
password: "password"
}),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function (data, status, headers, config) {
// handle success things
}).catch(function (data, status, headers, config) {
// handle error things
});这不是
$http.post('abc.php', {email: "abc@gmail.com",
password: "password"})
.then(function(res){
$scope.response = res.data;
})嗨,你能解释一下为什么第一个实现是有效的,第二个不是吗?我对短切和长切的角度方法非常困惑,谢谢提前
发布于 2017-11-01 18:41:31
第二个代码片段应该如下所示
$http.post('abc.php', {email: "abc@gmail.com",
password: "password"})
}).then(function(res){
$scope.response = res.data;
});https://stackoverflow.com/questions/47052954
复制相似问题