I've got this function that tests if a script is loaded:
function urlExists(url){
$.ajax({
url: url,
success: function(data){
//alert(url + ' exists');
console.log(url + ' exists');
return true
},
error: function(data){
//alert(url + ' failed to load');
console.log(url + ' failed to load');
return false
}
});
}
And then I call it in this fashion:
if (urlExists('file.js')) {
var rm = true;
}
But even if I get the console.log that the url exists, my var rm is still undefined.
I tried using Arun P Johny's solution like so:
urlExists('file.js', function(result){
if(result){
rm = true;
}
});
But rm is still undefined even if file.js exists and I get the console log that says so.