$(function() {
$.get('http://itunes.apple.com/cn/lookup?id=728200220', function(data) {
console.log(data);
});
})
링크에서 데이터를 얻고 싶습니다. 서버를 시작하여 오류가 발생했습니다.
XMLHttpRequest는 https://itunes.apple.com/cn/lookup?id=728200220을 로드 할 수 없습니다 . 요청 된 리소스에 'Access-Control-Allow-Origin'헤더가 없습니다. 따라서 원본 ' http : // localhost : 8080 '은 액세스가 허용되지 않습니다.
서버는 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
}
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다