I found a solution, which encourages the use of fetch() API , which bypasses the CORS error/block.
(我找到了一个鼓励使用fetch()API的解决方案,该解决方案绕过了CORS错误/块。)
However, I wasn't sure if there are any cons/disadvantages, to use this approach?
(但是,我不确定使用此方法是否有任何缺点/缺点?)
It seems it does what I need it to do.... to check a URL is exists on the internet:
(似乎它做了我需要做的事情。...检查Internet上是否存在URL:)
const url = "https://www.google.com/";
$.ajax({
url: url,
dataType: 'jsonp',
statusCode: {
200: function() {
console.log( "status code 200 returned" );
},
404: function() {
console.log( "status code 404 returned" );
}
},
error:function(){
console.log("Error");
}
});
(});)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…