访问控制允许来源错误?
Access-Control-Allow-Origin Error?
$(function() {
$.get('http://itunes.apple.com/cn/lookup?id=728200220', function(data) {
console.log(data);
});
})
我想从link获取数据,我启动了一个服务器,导致错误:
XMLHttpRequest cannot load https://itunes.apple.com/cn/lookup?id=728200220. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
服务器支持jsonp请求,所以使用它,例如:
$.ajax({
url: 'http://itunes.apple.com/cn/lookup?id=728200220',
// The name of the callback parameter
jsonp: "callback",
// Tell jQuery we're expecting JSONP
dataType: "jsonp",
// Work with the response
success: function( response ) {
console.log( response ); // server response
}
});
$(function() {
$.get('http://itunes.apple.com/cn/lookup?id=728200220', function(data) {
console.log(data);
});
})
我想从link获取数据,我启动了一个服务器,导致错误:
XMLHttpRequest cannot load https://itunes.apple.com/cn/lookup?id=728200220. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
服务器支持jsonp请求,所以使用它,例如:
$.ajax({
url: 'http://itunes.apple.com/cn/lookup?id=728200220',
// The name of the callback parameter
jsonp: "callback",
// Tell jQuery we're expecting JSONP
dataType: "jsonp",
// Work with the response
success: function( response ) {
console.log( response ); // server response
}
});