angular-seed POST 对每个浏览器的行为不同

angular-seed POST acts differently for each browser

我不确定我的 http post 方法发生了什么。从我读到的内容来看,我的安全性可能有问题,但我不确定情况是否如此或如何解决。对正确方向的任何见解都会很好。

我正在尝试 post 到 API 并检索返回的响应和 return 数据。当我在 IE 中 运行 POST 时,我得到了正确的响应。

然而,当我在 Chrome 中尝试这个时,我得到了奇怪的结果。我的 POST 变成了一个 OPTIONS 方法。状态代码为 200 OK,但我的回复为空白。当我尝试在没有 POST 的情况下直接转到 url 时,我在浏览器中显示了这个:

{"result":false,"error":"Authentication failed: Session authentication failed: No Host Name specified Authentication State: Invalid Login"}

这里是test.js(控制器)

var host = '255.255.255.255';
var creds = {'logintype':'1','host':host,'user':'Administrator','password':'1234','controlid':'ABC999'};
//var obj = JSON.stringify(creds);


angular.module('myApp.test', ['ngRoute'])
    .config(['$routeProvider', function($routeProvider) {
      $routeProvider.when('/test', {
      templateUrl: 'test/test.html',
      controller: 'TestCtrl',
      resolve: {
          friends: ['$http', function($http) {
          return $http({url: 'http://192.168.2.164/ISAPI/rip.dll/REST/SESSIONS/',method: 'POST', data: creds })
              .success(function (data) {
                  return data;
              })
              .error(function () {
                  return 'Error';
              });
      }]
  }
});
}])
.controller('TestCtrl', ['$scope', 'friends',function($scope,response) {
    $scope.response = response;
}]);

感谢 itsananderson,我能够解决我的问题。我正在发生,因为 Chrome 为跨域请求做了一些叫做 "preflight" 的事情。我需要将 API 移动到与该站点相同的服务器上 运行 避免跨站点脚本。