我正在使用jQuery來獲取跨域數據,但我得到這個錯誤如何使用jQuery獲取跨域數據?獲取錯誤
SyntaxError:missing;聲明 之前這裏是我的代碼
<script>
(function($) {
var url = '//heald-chiampa.tributes.com/funeral_homes/search?json=1';
$.ajax({
type: 'GET',
url: url,
async: false,
contentType: "application/json",
dataType: 'json',
success: function(json) {
alert(json);
},
error: function(e) {
console.log(e.message);
}
});
})(jQuery);
</script>
當我改變數據類型從JSONP成JSON然後我收到此錯誤 跨來源請求阻止:同源策略不允許在http://heald-chiampa.tributes.com/funeral_homes/search?json=1讀取遠程資源。 (原因:缺少CORS頭'Access-Control-Allow-Origin')。