Call and use php function in jquery

Call and use php function in jquery

I have the following php function.

public function dateIndaysoff($mydate=false){ if(!$mydate)return false; $host = "localhost"; $user = "user"; $pass = "pass"; $databaseName = "database"; $tableName = "table"; $con = mysql_connect($host,$user,$pass); $dbs = mysql_select_db($databaseName, $con); // $db=JFactory::getDbo(); $dbs->setQuery("select date from table WHERE `date`='$mydate'")->query(); return (int) $db->loadResult(); }

This function searches an input value inside a database table column and if it finds then we have a TRUE, else FALSE.

So, i have a jquery inside .js file where i execute a specific action and i want to check if i have a TRUE or FALSE result. In jquery i use a variable called val. So inside jquery in some place i want to have something like this:

if (dateIndaysoff(val)) {something}

Any ideas?