js判断请求的url是否可访问,支持跨域判断的实现方法

$scope.netping =function (url,e) {
url = $scope.urlForm.url;
$.ajax({
type: 'get',
cache: false,
url: url,
dataType: "jsonp", //跨域采用jsonp方式 
processData: false,
//timeout:10000, //超时时间,毫秒
complete: function (data) {
if (data.status==200) {
$scope.updateUrl(e);
} else {
layer.msg("无效链接");
}

}
});
}

转自:https://blog.csdn.net/oftoo/article/details/52858033

jQuery.ajax中success 和complete 区别:

文章详情:https://blog.csdn.net/zhbitxhd/article/details/9946799

猜你喜欢

转载自www.cnblogs.com/a565810497/p/11101873.html