gpt4 book ai didi

javascript - 带有 angularjs $http.post 请求的 Paypal

转载 作者:数据小太阳 更新时间:2023-10-29 05:29:57 26 4
gpt4 key购买 nike

这是购买东西的标准 Paypal 表格。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="you@youremail.com">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="0.00">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

我不想要这种形式,我想用angularJS做这个:

<button ng-click="checkOut()" class="btn btn-default">Buy</button>

this.checkOut = function () {
var data = {
... // handle all data
};

$http.post('https://www.paypal.com/cgi-bin/webscr', data).success(function (data) {
console.log("success " + data);
}).error(function (data) {
console.log("error " + data);
});
}

这给了我一个错误:

XMLHttpRequest cannot load https://www.paypal.com/cgi-bin/webscr. The request was redirected to 'https://www.paypal.com/home', which is disallowed for cross-origin requests that require preflight.

有什么建议,如何在没有表单的情况下使用 angularJS?

最佳答案

PayPal 不支持 CORS现在无法使用 $http POST 到 PayPal。

关于javascript - 带有 angularjs $http.post 请求的 Paypal ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21433236/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com