I try to call a function at different place. That why i return true or false. Problem i got is before hasCreditCard has time to do is call, that go directly to the else...
if (hasCreditCard($('#memberId').val())) {
...
}
else{
...
}
function hasCreditCard(memberId) {
var url = getHostName() + "/members/" + memberId + "/creditcard";
jQuery.ajax({
type: "head",
url: url,
contentType: "application/json",
headers: {
"Authorization": "Basic " + $.cookie('authorization')
},
success: function (data, status, jqXHR) {
if (jqXHR.status == 200) {
return true;
}
return false;
},
error: function (jqXHR, status) {
return false;
}
});
}