I am trying to call the user defined library function using ajax as below.
$(document).ready(function()
{
$("a.refresh").click(function()
{
jQuery.ajax(
{
type: "POST",
url: "<?php echo base_url(); ?>" + "application/libraries/Captcha_lib/captcha_refresh",
success: function(res)
{
if (res)
{
jQuery("span.image").html(res);
}
}
});
});
});
I'm getting the following response in firebug:
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
Note: If i put the captcha_refresh function in my Login controller and pass the URL to ajax like below
jQuery.ajax( { type: "POST", url: "" + "Login/captcha_refresh", ..... });
then it is working fine. However i don't want to do it.
Here is my captcha_refresh function:
public function captcha_refresh()
{
$values = array(
'word' => '',
'word_length' => 8,
'img_path' => './hrms_assets/captcha_img/',
'img_url' => base_url() .'hrms_assets/captcha_img/',
'font_path' => base_url() . 'system/fonts/texb.ttf',
'img_width' => '150',
'img_height' => 50,
'expiration' => 3600
);
$data = create_captcha($values);
$this->session->userdata['captchaWord'] = $data['word'];
echo $data['image'];
}