【问题标题】:How to grocery-crud grid reload without refreshing page如何在不刷新页面的情况下重新加载杂货网格
【发布时间】:2016-06-12 10:27:57
【问题描述】:

我是杂货店的新手,

我不知道如何在不刷新页面的情况下重新加载杂货网格。

目前我已经在 ajax 中重新加载了所有页面

    $.ajax({
        type:'POST',
        url: "<?php echo base_url() ?>user/user_function/"+dash_id,
        success: function(responses) {
            location.reload(); 
        }
    });

任何想法我需要做些什么来完成这项工作?谢谢!

【问题讨论】:

    标签: javascript ajax codeigniter grocery-crud


    【解决方案1】:

    创建一个带有网格格式的视图,并从带有“return”参数 = TRUE 的方法中加载它;

    然后,在ajax调用的响应中返回这个内容并加载到一个div中:

    在视图中,更改响应操作:

    <script>
    $.ajax({
        type:'POST',
        url: "<?php echo base_url() ?>user/user_function/"+dash_id,
        success: function(responses) {
            $('#result').html(responses); 
        }
    });
    </script>
    
    <div id="result"></div>
    

    在控制器的方法中,这样做:

    class User extends CI_Controller
    {
        public function user_function($dash_id)
        {
            $data_to_grid = array();
            ... // do your code and populate a $data array
    
            $result = $this->load->view('View_name', $data_to_grid, TRUE);
    
            header('Content-type: text/html;charset=utf-8');
            echo $result;
            return;
        }
    }
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-20
      • 2011-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-12
      • 2019-03-02
      相关资源
      最近更新 更多