jquery代码可以从另一个域名或其他网站调用Can服务吗?下面是我使用的代码,
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
url: "https://developers.google.com/public/oauth2/1/files",
headers: {
'Authorization': headerDATA,
'Content-Type': 'application/json'
},
success: function (data) {
alert("Success");
for (var i = 0; i < data.items.length; i++) {
alert(AJAX);
}
},
error: function (e) {
alert("Failure");
alert(JSON.stringify(e));
}
});如何解决这个问题?
发布于 2018-04-17 05:57:05
当然可以
你的问题是因为网址中没有双引号。ajax中的url字段应该是字符串值。试试下面的代码
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
url: "https://developers.google.com/public/oauth2/1/files",
headers: {
'Authorization': headerDATA,
'Content-Type': 'application/json'
},
success: function (data) {
alert("Success");
for (var i = 0; i < data.items.length; i++) {
alert(data.items[i]);
}
},
error: function (e) {
alert("Failure");
alert(JSON.stringify(e));
}
});https://stackoverflow.com/questions/49870752
复制相似问题