I am making a function in Jquery that validates the date given, by accessing checkdate.php using ajax. checkdate.php uses checkdate() and returns "success" if the date is valid. Here is my jquery function.
function checkdate(sample)
{
$.get('checkdate.php?dateSample='+ sample, function(data){
if(data == 'success')
return true;
else
return false;
});
}
checkdate.php works with no error and I'm sure of that but my problem is when I use this code ->
alert(checkdate('2013-09-22'));
or
alert(checkdate('123123123iuo12'));
it always alerts "Undefined"
I need Boolean result from checkdate function. Please help me.