JSFiddle - React, Tailwind, and code Playground
by apasaja
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
JavaScript
function UrlExists(url, cb){
jQuery.ajax({
url: url,
dataType: 'text',
type: 'GET',
complete: function(xhr){
if(typeof cb === 'function')
cb.apply(this, [xhr.status]);
}
});
}
UrlExists('http://www.google.com.com', function(status) {
if(status === 200) {
console.log('pass')
} else {
console.log('fail')
}
});