-2
$(function() {
    $.get('http://itunes.apple.com/cn/lookup?id=728200220', function(data) {
        console.log(data);
    });
})

I want to get the data from the link,I start a server,caused the error:

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.

Parker Song
  • 151
  • 10

1 Answers1

2

Server supports jsonp request, so use it, e.g:

$.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
    }
});
A. Wolff
  • 74,033
  • 9
  • 94
  • 155