I want to wait until ajax call complete and return the value.
function isFileExists(url) {
var res = false;
$.ajax({
type: "GET",
async: false,
url: url,
crossDomain: true,
dataType: "script",
success: function () {
res = true;
},
error: function () {
res = error;
},
complete: function () {
}
});
return res; //It is always return false
}
I want to return the value "true/error"
Please help me.