I am trying to call a controller function using ajax after clicking a button in a view. I am using Bonfire but there is no response at all. I need guidance. Below is my JQuery/Ajax code placed in a js file in the assets folder of one of my modules.
var base_url = '<? base_url()?>';
$('.tes_btn').click(function(){
var html_data = $(".admin-box").html();
$.ajax({
url: base_url + "test_module/reports/domPdfTest",
type: "POST",
data:"html_data="+ html_data,
success:function(result){
// alert('Good work');
}
});
});
the controller function looks like this
function domPdfTest(){
$dompdf = new DOMPDF();
$html = $this->input->post('html_data');
$this->dompdf->load_html($html);
$this->dompdf->render();
$this->dompdf->stream("test_report.pdf");
}
I Load the following in the constructor of my controller
$this->load->library('dompdf_gen');
Assets::add_module_js('test_module', 'test_module.js');
and my view button looks like this
<input type="button" id="tes_btn" value="tes btn" class="tes_btn"></input>
Is there anything am missing? Thanks in advance..Judas