doushou3814 2017-03-15 18:42 采纳率: 100%
浏览 52

数据表Ajax请求进入Codeigniter控制器

I am trying to send last value (af) of this URL www.example.com/country/AF.html through AJAX data and want to read this data in Codeigniter Controller but unable to retrieve data. Please help

Datatable Ajax Code

$(document).ready(function() {
    var UserURL = window.location.href.split("/").pop();
    var newurl = UserURL.split("/").slice(-1).join().split(".").shift();
    $('#countryiptable').DataTable({
        "pageLength": 50,
        "info": false,
        "processing": true,
        "serverSide": true,
        'ajax': {
            'url': "country/getlist",
            "type": "POST",
            "data":{"country_code": newurl},
            "dataType": "json",
            "dataSrc": function (jsonData){
                return jsonData.data;
            }
        }
    });
} );

and here is my Codeigniter Controller;

    public function getlist(){

        echo $this->input->post('country_code');
        $countryiso2    = strtoupper($this->input->post('country_code'));       
        //echo "hi";
        $list = $this->CountryModel->getCountry($countryiso2);

        $data = array();
        $no = $_POST['start'];
        foreach ($list as $iplist) {
        // print_r($data);die;
        $no++;
        $row = array();
        $row[] = $no;
        $row[] = $iplist->startip;
        $row[] = $iplist->registry_name;
        $row[] = $iplist->totalip;
        $row[] = $iplist->country_code;
        $row[] = $iplist->ip_type;

        $data[] = $row;

        //$_POST['draw']='';
        }

        $output = array(
            "draw" => $_POST['draw'],
            "recordsTotal" => $this->CountryModel->count_all(),
            "recordsFiltered" => $this->CountryModel->count_filtered(),
            "data" => $data,
        );
        //output to json format
       echo json_encode($output);
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器