【发布时间】:2014-08-13 12:43:09
【问题描述】:
我在尝试运行此代码时收到以下错误:
function getCurrentUser() {
yam.platform.request({
// yam.request({
url: "users/current.json", //this is one of many REST endpoints that are available
method: "GET",
data: {},
success: function (user) { //print message response information to the console
console.log("User request was successful.");
console.dir(user);
toggleLoginStatus(true);
$('#authResult').html('User Result:<br/>');
for (var field in user) {
$('#authResult').append(' ' + field + ': ' +
escape(user[field]) + '<br/>');
}
},
error: function (user) {
console.error("There was an error with the request.");
}
});
}
Error:
XMLHttpRequest cannot load https://api.yammer.com/api/v1/users/current.json?_=1407933095976. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://brillioonline.sharepoint.com' is therefore not allowed access.
我正在尝试使用以下代码来解决错误,但不知道这里是什么令牌:
$.ajax(
'https://app.asana.com/api/1.0/users/me',
{
type: 'GET',
dataType: 'json',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer $token")
},
complete: function (resp) {
console.log(resp);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus);
}
}
);
请帮帮我,我是初学者
【问题讨论】:
标签: jquery ajax http-headers jsonp yammer