I am fairly new to codeigniter, and can't seem to get this right. I have a bootstrap model which should display values from a database. Now the problem is that my requirement is to fetch the values from a database using AJAX, and insert it to the relevant fields[form inside Modal]. I know how to insert data into using AJAX, but have never used it to retrieve and populate something.
Please can someone solve this dilemma, I'm having this problem for hours now...
Onclick of a button, simply make a Ajax call to controller.
$('#button').click( function(){
$.ajax({
type: "POST",
url: "your url to controller function here",
}).done(function( html ) {
$(".bootstrap_modal").html(html);
});
In the controller function call a Model Function to run a query and get the result set.
Now
$data['result'] = $this->model_name->function_name();
$this->load->view('views/reveals/modal_content', $data);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.