当ajax函数调用codeigniter时,侧边栏滑动问题

时间:2016-01-28 05:15:25

标签: php ajax codeigniter codeigniter-2 codeigniter-3

我在codeigniter控制器中有一个使用ajax工作的添加功能。当单击边栏中的添加Rfq并再次尝试点击侧边栏上的任何其他链接时,它会自动关闭。为什么在侧边栏工作中会影响此功能?

enter image description here [![侧栏查看] 控制器功能

public function addrfqoffline() {
        $content = "";
        $this->load->helper(array('form', 'url'));

        $data['customers'] = $this->userdata_model->usersname();
        $data['merchants'] = $this->merchant_model->merchantname();
        // $data['mroproducts']=$this->mroproduct_model->mroproductname();
        $data['units'] = $this->requirement_model->fetchunits();
        if ($this->input->post("from") != "ajax") {
            $content .= $this->load->view('moderator/templates/header', '', true);
            $content .= $this->load->view('moderator/templates/sidebar', '', true);
            $content .= $this->load->view('moderator/mrorfq', $data, true);

            $content .= $this->load->view('moderator/templates/footer', '', true);
        } else {
            $rid = $this->input->post('reqid');
            $requirement = $this->requirement_model->viewdata($rid);
            if ($requirement) {
                foreach ($requirement as $reqdata) {
                    $dat['reqid'] = $reqdata->rqm_id;
                    $dat['service'] = $reqdata->rqm_service;
                    $dat['quantity'] = $reqdata->rqm_quantity;
                    $dat['service'] = $reqdata->rqm_service;
                    $dat['details'] = $reqdata->rqm_requirements;
                    $dat['unitrqm'] = $reqdata->rqm_unit;
                     $dat['userid'] = $reqdata->rqm_userid;
                    $unitname = $this->requirement_model->unitname($reqdata->rqm_unit);
                    foreach ($unitname as $unitsingle) {
                        $dat['unitname'] = $unitsingle->name;
                    }
                    $usernames= $this->requirement_model->username($reqdata->rqm_userid);
                    foreach($usernames as $username)
                    {

                        $dat['username']=$username->usr_name;
                         $dat['usercompany']=$username->usr_company;


                    }
                    if ($this->input->post("from") == "ajax") {
                        $content .= $this->load->view('moderator/mrorfq', array_merge($dat, $data), true);
                    }
                }
            } else if (!$requirement) {

                $content .= $this->load->view('moderator/mrorfq', $data, true);
            }
        }

        echo $content; // this will echo the view here
    }

补充工具栏代码

 <li class="treeview">
                <a href="#"><i class="fa fa-film"></i><span>Request for Quotation </span> <i class="fa fa-angle-left pull-right"></i></a>
                <ul class="treeview-menu"> 

                    <li><a href="<?php echo base_url() ?>moderator/RFQ/addrfqoffline"><i class="fa fa-plus"></i>New Offline RFQ</a></li>
                    <li><a href="<?php echo base_url() ?>moderator/RFQ/managerfq"><i class="fa fa-list"></i>Manage RFQ</a></li>
                </ul>
            </li> 

的Ajax

<script>
    function getValue(val) {
        //alert(val);
        $.ajax({
            type: "POST",
            url: "<?php echo base_url() ?>moderator/RFQ/addrfqoffline",
            data: {from: "ajax", reqid: val},
            success: function (data) {
                $("#content").html(data);
            }
        });
    }
</script>

<script type="text/javascript">

    $('#rfqsubmit').click(function () {

 var formData = new FormData($('#myform')[0]);
        $.ajax({
            url: "<?php echo base_url() ?>moderator/RFQ/addoffline",
            type: 'POST',
           data: formData,
           dataType:"Json", 
                mimeType: "multipart/form-data",
                contentType: false,
                cache: false,
                processData: false,
            success: function(data) {
                var last_inserted_id = data.id;
                window.location.href ="<?php  echo base_url() ?>moderator/RFQ/viewrfq/"+last_inserted_id;
                // window.location.href ="<?php //echo base_url()             ?>moderator/RFQ/viewrfq/"+  form_data.reqid;
//      alert('added Successfully');
            }
        });

        return false;
    });



</script>

0 个答案:

没有答案