【发布时间】:2016-05-21 17:54:21
【问题描述】:
我制作了一个带有 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 / 我的服务器配置有关,但我无法解决它,直到现在我发现没有任何帮助。
【问题讨论】:
标签: angularjs http-status-code-403