如何在 https 中 angularjs 上 post

How to post on angularjs in https

这是我的 angularjs 请求,每当我提交请求时它 returns 错误并且没有延迟。

   var req = $http({
            method: 'POST',
            url: 'https://localhost:44300/authentication/login',
            data: { UserID: Username, Password: Password },
            dataType: "json"
        });

        req.success(
            function (result) {
                 alert('success');
            });
        req.error(function (result) {
                 alert('something went wrong');
        });

提前致谢。

我就是这样做的,它总是很好

var deferred = $q.defer();
var url = 'your url';
$http({
       method: 'POST',
       url: url,
       data: {}
      })
      .then(function(data, status, headers, config) {
            deferred.resolve(data);
      })
      .catch(function(data, status, headers, config) {
            deferred.reject(msg);                        
      });

      return deferred.promise;