I need a global function that checks if a file exists. I need to reuse that function for several methods so I just want it to return true or false. I tried to make it asynchronous but I can't get it to work. This is the function:
function checkIndex(){
$.ajax({
url:'upload/_3.fdt',
type:'HEAD',
async: false,
error: function(){
return false;
},
success: function(){
return true;
}
});
}
this is one the functions that calls the checkIndex()
$(function(){
$(document).ready( function(){
if(checkIndex() == false)
$('#check').html('<td><img src="img/cross.gif" /></td><td>No index present</td>');
else
$('#check').html('<td><img src="img/check.gif" /></td><td>Index is present</td>');
});
});
How can I make this work?