简体   繁体   English

使用Codeigniter通过AJAX将数据从数据库传递到Bootstrap Modal

[英]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.

相关问题 通过Bootstrap模态将循环数据作为变量从JavaScript传递到AJAX - Passing loop data as variable from JavaScript to AJAX via Bootstrap modal 使用AJAX从引导模式更新数据库 - Update database from bootstrap modal using AJAX 如果使用Codeigniter成功,则使用Ajax将数据插入数据库并显示模式 - insert data to database using ajax and show modal if success with codeigniter 如何在php codeigniter中使用ajax从数据库中获取数据并以模式显示? - How can I get data from database using ajax in php codeigniter and display it in modal? 使用AJAX在codeigniter中更新表单模式引导程序 - UPDATE form modal bootstrap in codeigniter using AJAX 使用Codeigniter和jquery在Modal Bootstrap 3中用DB中的数据填充字段 - populate field with data from DB in Modal Bootstrap 3 using Codeigniter and jquery 使用bootstrap codeigniter从控制器发送数据到弹出模式 - Send data from controller to pop up modal using bootstrap codeigniter 使用Ajax将值放在Spring MVC中的引导程序模式弹出字段值内,以从数据库获取数据 - Place values inside bootstrap modal popup field value in spring MVC using ajax to get the data from database 未使用模式引导程序和代码初始化器插入数据 - Data not inserted using modal bootstrap and codeigniter 如何使用bootstrep模态代码igniter显示数据库中的详细数据? - How to display the detailed data from the database using bootstrep modal codeigniter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM