0
AJAXで作業するのが初めてです。私はdivの内容を外部サイトから取得して自分のサイトに戻したいと考えています。AJAXを使用して外部サイトからdivの内容を取得
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script type="text/javascript" src="get-page-content.js"></script>
</head>
<body>
<h1>Page content should go here:</h1>
<div id="here"></div>
</body>
</html>
そして、私の.jsスクリプトの:ここで
は、私が現在持っているコードです
$.ajax({
url: 'http://www.spotlight.com/6298-9058-7917',
type: 'GET',
success: function(res) {
var data = $.parseHTML(res);
$(data).find('.skills').each(function(){
$('#here').append($(this).html());
});
}
});
予想したように、それは、同じサーバー上の外部サイトの場合、これは、しかし、作品別のドメインから情報を取得しようとすると、次のエラーが表示されます。No 'Access-Control-Allow-Origin' header is present on the requested resource.
このエラーを回避するには何かできますか?
可能な複製(http://stackoverflow.com/questions/2558977/ajax-cross-domain-call) –
参照してください[HTTP:/ /stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource](http://stackoverflow.com/questions/20035101/no-access-制御許可元ヘッダは、要求されたリソース上に存在する) –