[英]Passing Data to Bootstrap Modal from database using codeigniter via AJAX
I am fairly new to codeigniter, and can't seem to get this right. 我对Codeigniter相当陌生,似乎无法正确解决。 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].
现在的问题是,我的要求是使用AJAX从数据库中获取值,然后将其插入到相关字段中[在Modal中形成表格]。 I know how to insert data into using AJAX, but have never used it to retrieve and populate something.
我知道如何使用AJAX插入数据,但从未使用过它来检索和填充某些内容。
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. 单击按钮后,只需对控制器进行Ajax调用即可。
$('#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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.