Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
Javascript 代码点火器控制器JS(AJAX)问题_Javascript_Ajax_Codeigniter - Fatal编程技术网

Javascript 代码点火器控制器JS(AJAX)问题

Javascript 代码点火器控制器JS(AJAX)问题,javascript,ajax,codeigniter,Javascript,Ajax,Codeigniter,我的CI代码有问题。我无法访问登录控制器的身份验证方法。我的浏览器窗口中出现404错误。 这是我的密码 <!--This will serve as the form --> <nav class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <!-- Brand and toggle get grouped for b

我的CI代码有问题。我无法访问登录控制器的身份验证方法。我的浏览器窗口中出现404错误。

这是我的密码

 <!--This will serve as the form -->
    <nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <a class="navbar-brand" href="">Brand</a>
        </div>       
        <form role="form" class="navbar-form navbar-right login-form">
            <div class="form-group">
                <input type="text" placeholder="Username" class="form-control"  name="username">
                <input type="password" placeholder="Password" class="form-control" name="password">
            </div>
            <input type="submit" class="btn-default btn" value="Login" id="btn-login">
        </form>
      </div><!-- /.container-fluid -->
      </nav>

这是使用authenticate()方法的登录控制器


您应该检查/共享您的路由$route['default_controller']=“login”;这是我的路线。
http://localhost/hci/login/authenticate
在浏览器中点击此链接,告诉我是否显示页面未找到错误?是否设置了
.htaccess
?如果没有,请在浏览器中尝试此操作
http://localhost/hci/index.php/login/authenticate
。如果是,请发布。
.htaccess
应位于CI安装的根目录中(在您的案例hci目录中),您可以阅读有关在Codeigniter中删除index.php的
内容,这是您案例中的问题。还是在这里
<?php

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

class Login extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->model('user');
    }

    public function index() {
        $this->load->view('login');
        $this->template->set_layout('default');
        $this->template->set_partial('nav', 'partials/nav');
        $this->template->append_metadata('<script src="' . base_url("js/script.js") . '"></script>');
        $this->template->build('login');    
    }

    public function authenticate() {
        $error=0;
        $username = $this->input->post('username');
        $password = $this->input->post('password');

        if ($this->user->login($username, $password)) {
            $error=0;
            echo json_encode(array('status' => 'success', 'error' => $error));
        } else{
            $error=1;
            echo json_encode(array('status' => 'error', 'error' => $error));
        }

        echo json_encode(array('status' => 'success', 'error' => $error));
    }

}