I have a function defined in my helper function in codeigniter that returns the formatted price when val and currency id is passed to it.
if(!function_exists('format_price')){
function format_price($val,$curency_id=NULL){
$CI =& get_instance();
$CI->load->model('currency_model');
if ($curency_id) {
$Result=$CI->currency_model->getcurrency($curency_id);
$dec_place=round($Result['decimal_place']);
$value=number_format((float)$val,$dec_place,'.',',');
return $Result['symbol_left'].$value ." ".$Result['symbol_right'];
}
else{
$Result=$CI->currency_model->getDefaultCurrency();
$dec_place=round($Result['decimal_place']);
$value=number_format((float)$val,$dec_place,'.',',');
return $Result['symbol_left'].$value ." ".$Result['symbol_right'];
}
}
}
What I need is to call this function through ajax in javascript code. is this possible without a controller, or do I have to make a controller?