I have this code (The problem is that i can't get a returned value from result file):
function resultit(id) {
var res;
$.ajax({
url: "result",
type: 'POST',
data: "id=" + id,
success: function (result) {
res = result;
if (result == 0) {
alert('warning', 'FAILED !');
} else {
alert('danger', 'SUCCESS !');
}
}
});
return res;
}
alert(resultit(id)); // always undefined
Can you suggest any modification to get the returned value please ? thank you in advance.