I just want to call a function and get a true/false and depending on that set a button to enabled/disabled.. but instead it skips right over the function before the function finished!! I am a C# guy so I have a feeling I am trying to do things the c# way in javascript and its not correct
if (IsTasksExists()) {
$("#divValidateUnprocessData").button("enable");
}
else {
$("#divValidateUnprocessData").button("disable");
}
});
function IsTasksExists() {
$.ajax(
{
type: 'POST',
url: 'http://localhost:7000/ManualProcess/CheckTasksToValidateAJAX',
success: function (response) {
if (response.Status == 'OK') {
if (response.TasksToValidate == 0) {
// $("#divValidateUnprocessData").button("disable");
return false;
}
else {
return true;
}
}
else {
alert('error');
}
}
});
}