我有這樣的代碼:爲什麼不執行跨越來源策略?
$.getJSON("https://restcountries.eu/rest/v2/name/" + $("#nameOfCountry").val(),
{ fullText: "true" }, function (data) {
console.log(data[0]);
$('#answer').html(data[0].capital);
});
我從其他服務器的響應。 所以我的問題是:爲什麼瀏覽器不在這裏強制執行交叉來源策略?
因爲服務器這樣說:'訪問控制 - 允許來源:*' – Andreas
它被稱爲CORS,請參閱https://en.wikipedia.org/wiki/Cross-origin_resource_sharing – CBroe