I have a PHP function which returns an array :
function lire( $id) {
$ret = array() ;
$sSQL = \"SELECT * FROM produit WHERE prod_code
In AJAX you make simple HTTP request to some web resource. To get the data from your function you can provide simple php script which will have url parameter (id) and call your function. Than you
can use suitable Javascript libaray (e.g. jQuery) to call the page with that parameter.
function lire( $id) {
$ret = array() ;
$sSQL = "SELECT * FROM produit WHERE prod_code = '$id' LIMIT 1" ;
$this->db->query($sSQL) ;
$ret['cnt'] = $this->db->num_rows() ;
return $ret;
}
$result = lire($_GET['id']); // CONSIDER SOME ESCAPING OF USER INPUT FOR SECURITY!
echo $result; // OR USE SOME OTHER SORT OF SERIALIZATION (e.g. JSON)
Maybe you will have to set the headers (MIME type of the result).