5

我在 AngularJS 应用程序中有一个简单的 CORS AJAX 调用,并带有成功回调:

$http({method:'POST',url:"http://0.0.0.0:4567/authenticate", 
 params: {Lusername:scope.Lusername,Lpassword:scope.Lpassword}})
 .success(function(){alert("Success")})

在 Safari 中使用时,它工作正常:返回预期的 JSON 对象并显示警告框。但是在 Firefox 中,虽然正确返回了 JSON 对象,但不会触发成功回调。

知道为什么吗?

4

2 回答 2

1

确保在服务器中处理 OPTIONS 请求。如果它返回 404,那么 Firefox 将不会调用下一个请求(在您的情况下是上面提到的 POST)。

于 2013-06-10T23:14:37.857 回答
0

用最新版本的 AngularJS 试试这个:

$http.post("http://0.0.0.0:4567/authenticate", {
  Lusername: $scope.Lusername, 
  Lpassword: $scope.Lpassword
}).success(function(data, status, headers, config) {
   alert("Success");
});
于 2013-07-16T07:52:55.593 回答