如何消除角客户端中的“访问控制 - 允许 - 来源?

时间:2016-08-01 11:45:31

标签: angularjs

表单提交后,页面重定向到支付网关页面。 成功或失败后,页面将重定向到相应的页面 /成功或/失败

脚本

 $http({
          url: "https://secure.payu.in/_payment",
          method: "GET",
          }).success(function(data, status, headers, config) {
                console.log(data)
                 console.log(status)
           }).error(function(data, status, headers, config) {
                    $scope.status = status;
                    console.log(status)
           });
$scope.payemntProceed=function(checkout){
$scope.payment.txnid=Math.floor(100000000000+(Math.random()*900000000000));
$scope.payment.salt="HseUIoSb"
$scope.payment.key="WHlKGc";
$scope.payment.amount=1;
$scope.payment.productinfo=$rootScope.cartlist
$scope.payment.firstname=$rootScope.userinfo.name;
$scope.payment.email=$rootScope.userinfo.email
$scope.payment.phone=$rootScope.userinfo.contactno;
$scope.payment.surl="http://localhost/august1stZustshop/#/home"
$scope.payment.furl="http://localhost/august1stZustshop/#/checkout"
$scope.payment.service_provider="payu_paisa"
var string = $scope.payment.key + '|' + $scope.payment.txnid + '|' + $scope.payment.amount + '|' + $scope.payment.productinfo + '|' + $scope.payment.firstname + '|' + $scope.payment.email + '|||||||||||' + $scope.payment.salt;
$scope.payment.hash = $scope.SHA512(string);
}

控制台显示如下:

XMLHttpRequest cannot load https://secure.payu.in/_payment.
No 'Access-   Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost' is therefore not allowed access.
status is -1.

始终执行失败代码。显示状态为-1。

form.html

<form action="https://secure.payu.in/_payment" method="post" ng-submit="payemntProceed(checkout)">
 <input type="text" ng-model="payment.txnid"  name="txnid" >
 <input type="text" ng-model="payment.key"  name="key" >
 <input type="text" ng-model="payment.amount"  name="amount" >       
 <input type="text" ng-model="payment.productinfo"  name="productinfo" >
 <input type="text" ng-model="payment.firstname" name="firstname" >
 <input type="text" ng-model="payment.email"  name="email" >
 <input type="text" ng-model="payment.phone"  name="phone" >         
 <input type="text" ng-model="payment.hash" name="hash" >
 <input type="text" ng-model="payment.surl"  name="surl" >
 <input type="text" ng-model="payment.furl"  name="furl">
 <input type="text" ng-model="payment.service_provider"  name="service_provider">
 <button type="submit">submit</button>

请告诉我如何删除跨源问题。我正在使用payu-money支付网关。

2 个答案:

答案 0 :(得分:0)

在仍然发出请求的同时,从客户端停止XHR跨源错误的唯一方法是不使用XHR。

删除调用$http的JavaScript并正常提交表单。

答案 1 :(得分:0)

https://secure.payu.in/_payment接受普通表单提交的POST方法。