HTTP请求上的404

当我尝试向Codeigniter路由发出Ajax请求时,出现404错误


项目的根文件夹是 http://localhost/control_cuotas/


这是控制器(索引有效):


<?php

defined('BASEPATH') OR exit('No direct script access allowed');


class Control_cuotas_controller extends CI_Controller {


    public function index()

    {

        $data = array();

        $tables = $this->getTables();

        $data['tables'] = $tables;

        $this->load->view('main/main_view', $data);      

    }


    public function getData($data){

        var_dump($data);

    }


    private function getTables(){


        $sql = "SELECT TABLE_NAME " 

            ."FROM INFORMATION_SCHEMA.TABLES "

            ."WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME LIKE 'datos_%'";

        $query = $this->db->query($sql);

        $tables = array();


        foreach ($query->result() as $row){

            $name = substr($row->TABLE_NAME,0,-2);

            if(!in_array($name,$tables)){

                array_push($tables, $name);

            }

        }


        return $tables;

    }

这是javascript:


$(document).ready(function(){


    $('#tables').change(function(){

        var selected = $(this).val();

        $.ajax({

            url:'getData/'+selected

        });

    });

});

}

这是路线


$route['getData/(:any)']['GET'] = 'control_cuotas_controller/getData/$1';

该请求是在以下网址上完成的


http://localhost/control_cuotas/getData/selected_value


浮云间
浏览 136回答 2
2回答

鸿蒙传说

请检查.htaccess文件并尝试此代码;RewriteEngine onRewriteCond $1 !^(index\.php|public|\.txt)RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php?$1或者$(document).ready(function(){&nbsp; &nbsp; $('#tables').change(function(){&nbsp; &nbsp; &nbsp; &nbsp; var selected = $(this).val();&nbsp; &nbsp; &nbsp; &nbsp; $.ajax({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url:'http://localhost/control_cuotas/getData/'+selected&nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; });});}
打开App,查看更多内容
随时随地看视频慕课网APP