[英]How to Eliminate the "Access-Control-Allow-Origin in the angular client side?
表單提交后,頁面重定向到支付網關頁面。 成功或失敗后,頁面將重定向到相應的頁面,如/ success或/ failure
腳本
$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支付網關。
在仍然發出請求的同時,從客戶端停止XHR跨源錯誤的唯一方法是不使用XHR。
擺脫調用$http
的JavaScript並正常提交表單。
https://secure.payu.in/_payment接受正常表單提交的POST方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.