JSFiddle - React, Tailwind, and code Playground
by gschutz
JavaScript
var isAccessible = null;
function checkConnection() {
var url = "http://localhost:8194/" ;
$.ajax({
url: url,
type: "get",
cache: false,
dataType: 'jsonp', // it is for supporting crossdomain
crossDomain : true,
asynchronous : false,
jsonpCallback: 'deadCode',
timeout : 1500, // set a timeout in milliseconds
complete : function(xhr, responseText, thrownError) {
console.log(xhr.status, xhr.statusText, xhr);
if(xhr.status == "200") {
isAccessible = true;
console.log(isAccessible)
}
else {
isAccessible = false;
console.log(isAccessible)
}
}
});
}
checkConnection(); // here I invoke the checking function