
const checkUrl = function (url) {
const promise = new Promise(function (resolve, reject) {
if (!url) reject('无效路径');
$.ajax({
url: url,
type: 'GET',
dataType: "jsonp", //跨域采用jsonp方式
complete: (response)=> {
if(response.status==200)
resolve(true)
else
resolve(false)
}
});
});
return promise;
}
checkUrl('https://www.example.com').then(res=>{
if(res){
console.log('当前链接有效')
}else {
console.log('当前链接无效')
}
});
jQuery语法如何实现table隔行交替背景色(具体代码介绍)
上面是“jQuery检测指定链接(URL)是否有效(包含跨域)”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_15612.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

织梦DEDECMS验证码不显示的完美解决方法