jQuery function return true or false, returning only false while it's all good
I don't know how to fix it and what wrong.
So far i got to this , the code :
the onclick function:
$(document).on('click', '.founditems', function (e) {
var $this = $(this)
var k = $this.attr('href');
if (checkUserSystem(k) == true) {
alert("good");
} else {
alert("bad");
}
});
the ajax function:
function checkUserSystem(k) {
var starttime = $.trim($('#checkusersystemstartime').val());
var k = k;
var dataString = 'k=' + k + '&starttime=' + starttime;
$.ajax({
type: "POST",
url: "r.php?proc=sendCp",
data: dataString,
dataType: 'json',
beforeSend: function () {
},
complete: function () {
},
success: function (data) {
if (data.message == false) {
return false;
} else if (data.cblocked == true) {
return false;
} else {
return true;
}
}
});
return false;
}
The function always return false when it's working perfect and the PHP return true, And if I remove return false; at the end of the ajax code, it will return undefined instead of true any idea?
Thanks.