【发布时间】:2014-07-18 06:02:30
【问题描述】:
我有一个 URL,它在浏览器上给出响应: https://api.sandbox.paypal.com/retail/merchant/v1/locations
它给出:
{
"errorCode": 600031,
"message": "Missing access token",
"developerMessage": "You must provide an access token when calling this API. It can be passed as either a header of the form \"Authorization: Bearer \" or as a query parameter called access_token.",
"errorType": "oauth/missing_access_token",
"correlationId": "4de95cd8aa090"
}
我试过了:
$.ajax({
url: "https://api.sandbox.paypal.com/retail/merchant/v1/locations",
dataType: 'json',
type: 'POST',
success: function (data) {
console.log(data);
alert("success", data);
},
error: function (data) {
alert("fail", data);
console.log(data);
alert("Sorry..Please try again later");
},
});
但我没有得到与浏览器相同的响应。我遇到了错误。
请在此处查看 http://jsfiddle.net/ajitksharma/wehGy/
但是在浏览器控制台上调试时出现错误:
XMLHttpRequest 无法加载 https://api.sandbox.paypal.com/retail/merchant/v1/locations。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,Origin 'null' 不允许访问。
【问题讨论】:
-
是服务器端错误
-
我检查了,似乎服务器端响应是正确的 JSON 格式,我没有在服务器端更改的选项
-
您必须提供访问令牌才能成功运行。
标签: javascript jquery ajax json paypal