Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter-从ajax响应中分离两个视图_Codeigniter_Jquery - Fatal编程技术网

Codeigniter-从ajax响应中分离两个视图

Codeigniter-从ajax响应中分离两个视图,codeigniter,jquery,Codeigniter,Jquery,我使用Ajax将数据存储到数据库中,并在控制器函数中加载了两个视图。现在,作为回应,我得到了两种观点的两个内容。有人能告诉我怎样才能把这两个部门分开吗 我的ajax代码如下: $.ajax({ url:base_url+'welcome/add_group_to_archieve', type:'post', data:data, success:function(response){ $(".group_v

我使用Ajax将数据存储到数据库中,并在控制器函数中加载了两个视图。现在,作为回应,我得到了两种观点的两个内容。有人能告诉我怎样才能把这两个部门分开吗

我的ajax代码如下:

$.ajax({
        url:base_url+'welcome/add_group_to_archieve',
        type:'post',
        data:data,
        success:function(response){
            $(".group_value").html(response);               
            alert(response);
            get_groups_list();
            $(".archieves_list").html(response);
        },
        error:function(){
            alert('ajax failure');
        }

    });
控制器:

public function add_group_to_archieve() {
        $user_id = $this->tank_auth->get_user_id();
        $archieve_selected = $this->input->post('archieve_selected');
        $this->s_model->insert_as_archieve($archieve_selected);
        $data['get_archieved_groups'] = $this->s_model->get_archieved_groups();
        $data['retrieved_group_values'] = $this->s_model->retrieve_group_post();
        $data['file_id'] = $this->s_model->get_profile_picture($user_id);
        $data['edited_content'] = $this->s_model->get_save($user_id);
        $this->load->view('ajax_response_archieved_groups_list', $data);
        $this->load->view('ajax_response_archieved_groups_select', $data);
    }
型号:

  function get_archieved_groups() {
        $this->db->select('*');
        $this->db->where('archieved', 'archieved');
        $data = $this->db->get('groups');

        return $data->result();
    }
第1部分:


归档组标记
第2部分:



明白了,只是做了两个单独的函数来加载不同的视图,并调用了两个不同的ajax响应。 以下是我的ajax代码:


没有可靠的信息,谁能告诉你?没有密码或者你的挣扎没有答案?请提供更多信息。为什么有两次加载视图$此->加载->查看('ajax\u响应\u归档\u组\u列表',$data)$此->加载->查看('ajax\u响应\u归档\u组\u选择',$data);如果希望一次只加载一个视图,请在加载视图之前添加一些条件。
<div class="archieves clearfix" id="ajax_response_archieved_groups_list">
    <div class="archieves_list">
        <h6>Archieved Group Tags</h6>
        <? //php echo '<pre>'; print_r($get_archieved_groups[0]); echo '</pre>'; exit; ?>
        <ul><?php
        if (isset($get_archieved_groups)) {
            foreach ($get_archieved_groups as $row) {
                ?>
                    <li><?php if (isset($row->group_name)) { ?><?php
                echo $row->group_name;
            }
                ?></li>


                    <?
                }
            }
            ?>
        </ul>
    </div>
</div>
<div class="creating archieves" id="ajax_response_archieved_groups_select1">
    <select id="archieves_select_box">
        <option value="<?php echo "All"; ?>"><?php echo "All"; ?></option>
        <?php foreach ($get_archieved_groups as $row) { ?>

            <option value="<?php echo $row->group_name; ?>"><?php echo $row->group_name; ?></option>        
        <?php } ?>


    </select>
</div>
$.ajax({
        url:base_url+'welcome/add_group_to_archieve',
        type:'post',
        data:data,
        success:function(response){
            $(".group_value").html(response);               
            alert(response);
            get_groups_list();
            $(".archieves_list").html(response);
            archieved_select();
},
error:function(){
    alert('ajax failure');
}     
});
function archieved_select(){
     $.ajax({
    url:base_url+'welcome/add_group_to_archieve_select',
    type:'post',
    data:data,
    success:function(response){
    $("#ajax_response_archieved_groups_select1").html(response);
},
error:function(){
    alert('ajax failure');
}    
});