js verification url Is it effective , Support cross domain authentication

background : Sometimes we don't just verify url Is it correct , You also need to verify that you can actually access it

principle : After regular check , Then use ajax To simulate requests , Responsive 200, explain url True and effective , Cross domain application jsonp, The shorter the timeout, the better .
$.ajax({ type: 'get', cache: false, url: url, dataType: "jsonp",
// Cross domain adoption jsonp mode processData: false, timeout:1000, // Time out , millisecond complete: function
(data) { if (data.status==200) { if($('input[name=is_link_origin_url]').val()
== '1'){ $('input[name=is_link_origin_url]').val('0'); }else {
$('input[name=is_link_origin_url]').val('1'); } } else {
$('#check-btn').removeAttr('checked');
$('input[name=is_link_origin_url]').val('0'); alert(" Invalid link "); } } });
 

Technology
Daily Recommendation