预检的响应具有无效的HTTP状态代码403-离子应用程序错误

时间:2016-11-18 08:08:26

标签: angularjs ionic-framework angularjs-scope angular-ui-router

嘿得到上面提到的错误。它在移动设备上正常运行但在浏览器上没有运行.preflight具有无效的HTTP状态代码403.后端开发人员说他已经在后端完美编码了所有内容。所以,如果前端有可能,请告诉我。我已经在chrome中下载了“CORS”扩展名。

Controller.js

.controller('LoginCtrl', function($scope, $http,$rootScope,$window,$location,$state) {
$scope.formData = {};
$scope.processForm = function() {
$http({
  method  : 'POST',
  url     : 'http://abc/login',
  data    : $.param($scope.formData),
  headers : { 'Content-Type': 'application/x-www-form-urlencoded', 'X-API-KEY': 'abcfjo-jrabc-ltjerabcabcabc' }
 })
.success(function (data, status, headers, config) {
            $scope.foo = data;
            $state.go('tab.dash');
              // $location.path('#/tab/new-order');


        })
        .error(function (data, status, header, config) {
            $window.alert("username or password incorrect");
        });
};

})

HTML

<form action="" class="ki-login-form" method="post" accept-charset="utf-8"  >
                <div class="form-group username">
                    <input type="text" class="form-control" name="username" ng-model="formData.username" value="" id="identity" placeholder="Your Name">
            </div>
                <div class="form-group pin">
                    <input type="text" class="form-control" name="password" ng-model="formData.password" value="" id="identity" placeholder="Your Pin">
                </div>
                <a type="submit" class="btns" ng-click="processForm(formData.username,formData.username)">Login</a>
        </form>

app.js

angular.module('starter', ['ionic','starter.controllers', 'starter.services', 'ngCordova'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  cordova.plugins.Keyboard.disableScroll(true);

}
if (window.StatusBar) {
  // org.apache.cordova.statusbar required
  StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider,$httpProvider) {
   $stateProvider
    .state('tab', {
    url: '/tab',
    abstract: true,
    templateUrl: 'templates/tabs.html'
  })

错误XMLHttpRequest无法加载http://abc/login。预检的响应具有无效的HTTP状态代码403

0 个答案:

没有答案