使用angular(post)在http请求期间出现403错误

时间:2016-05-21 17:54:22

标签: angularjs http-status-code-403

我使用angularJS验证制作了一个表单,我的代码在localhost中工作正常。当我尝试在我的网络服务器上传我的整个代码时,我在angular.min.js文件的第72行遇到403错误(禁止)。

我尝试了很多解决方案而且我坚持这个问题。

以下是我在javascript文件中的内容,问题似乎来自我的服务器或因为403错误而我甚至没有进入我的insert.new.php文件。

function FrmController($scope, $http) {
    $scope.errors = [];
    $scope.msgs = [];
    $scope.titles = [];

    $scope.SignUp = function() {

        $scope.errors.splice(0, $scope.errors.length); // remove all error messages
        $scope.msgs.splice(0, $scope.msgs.length);
        $scope.titles.splice(0, $scope.titles.length);

        $http.post('insert.new.php', { 'uname': $scope.username, 'email': $scope.useremail }).success(function(data, status, headers, config) {
            if (data.msg != '') {
                $scope.titles.push(data.title);
                $scope.msgs.push(data.msg);
                sendContactForm();
            } else {
                $scope.titles.push(data.title);
                $scope.errors.push(data.error);
                sendContactForm();
            }
        }).error(function(data, status) { // called asynchronously if an error occurs
            // or server returns response with an error status.
            $scope.titles.push(data.title);
            $scope.errors.push(status);
            sendContactForm();
        });
    }

}

我试图将.htaccess放在我网站的根目录下,该文件包含

Order Allow,Deny
Allow from all

我没有更改我的网络服务器本身的任何内容,它有一个“防火墙”,我试图禁用,以防它可以提供帮助,但这并没有解决任何问题。

使用AngularJS 1.2.3(此版本是使用此代码的最高版本)

当我提交时,在Chrome的“来源”标签中我得到:

angular.min.js:72 POST http://domain.com/insert.new.php 403 (Forbidden)
angular.min.js:72 XHR finished loading: POST 
"http://domain.com/insert.new.php".

我认为很有可能它与apache /我的服务器配置有关,但我无法解决它,直到现在我找到的任何东西都没有帮助我。

1 个答案:

答案 0 :(得分:0)

我刚刚解决了我在所有文档中放置.htaccess的问题,一根在根本上是不够的,所以问题解决了!

相关问题