运行以下代码时,出现 CORS 错误并收到“FAIL”警报。怎么做才能让它成功而不是失败。请建议。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>XML Data Load Test</body>
<script>
$(function() {
$.ajax({
type: "GET" ,
url: 'https://www.w3schools.com/xml/plant_catalog.xml',
dataType: "xml" ,
success: function() {
alert("Success");
},
error: function() {
alert('Fail');
}
});
});
</script>
</html>
获取错误和警报为“失败”