Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.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 当我在codeigniter中使用jquery发出警报时,没有发生任何事情_Javascript_Php_Jquery_Codeigniter - Fatal编程技术网

Javascript 当我在codeigniter中使用jquery发出警报时,没有发生任何事情

Javascript 当我在codeigniter中使用jquery发出警报时,没有发生任何事情,javascript,php,jquery,codeigniter,Javascript,Php,Jquery,Codeigniter,Jquery/Javascript无法在codeigniter中工作。我所做的是 在config.php中I包含 $config['javascript_location'] = 'libraries/javascript/jquery.js'; $config['javascript_ajax_img'] = 'images/ajax-loader.gif'; public function __construct() { parent::__construct();

Jquery/Javascript
无法在codeigniter中工作。我所做的是

config.php中
I包含

$config['javascript_location'] = 'libraries/javascript/jquery.js';
$config['javascript_ajax_img'] = 'images/ajax-loader.gif';
public function __construct()
    {
        parent::__construct();
        $this->load->library('javascript');
        $this->load->library('javascript/jquery');
    }
    public function index()
    {
        $data['library_src'] = $this->jquery->script();
        $data['script_head'] = $this->jquery->_compile();

        $this->load->view('register', $data);
    }
<?php $this->jquery->click('#username', $this->jquery->alert("hi")); ?> 
controller/welcome.php中
I包含

$config['javascript_location'] = 'libraries/javascript/jquery.js';
$config['javascript_ajax_img'] = 'images/ajax-loader.gif';
public function __construct()
    {
        parent::__construct();
        $this->load->library('javascript');
        $this->load->library('javascript/jquery');
    }
    public function index()
    {
        $data['library_src'] = $this->jquery->script();
        $data['script_head'] = $this->jquery->_compile();

        $this->load->view('register', $data);
    }
<?php $this->jquery->click('#username', $this->jquery->alert("hi")); ?> 
views/register.php
I中包括

$config['javascript_location'] = 'libraries/javascript/jquery.js';
$config['javascript_ajax_img'] = 'images/ajax-loader.gif';
public function __construct()
    {
        parent::__construct();
        $this->load->library('javascript');
        $this->load->library('javascript/jquery');
    }
    public function index()
    {
        $data['library_src'] = $this->jquery->script();
        $data['script_head'] = $this->jquery->_compile();

        $this->load->view('register', $data);
    }
<?php $this->jquery->click('#username', $this->jquery->alert("hi")); ?> 

但什么也没发生。没有显示错误。如何在
Codeigniter
中生成
jquery/Javascript
事件。与此相关的问题被其他人问到,但我还没有找到解决方案。所以不要将此标记为重复

谢谢

编辑


在CI中使用jquery的任何替代方式(任何方式)。简单地说,我如何在CI中使用jquery。

我建议您将jquery作为javascript使用,而不是codeigniter附带的版本,因为它可能是旧版本,但您可以在项目根目录上名为资产/js的新文件夹中使用javascript库

并将其包括在视图中,如下所示

<html>
     <head>
          <script src="<?=base_url()?>/assets/js/jquery.js" type="text/javscript"></script>
<script>
     $(document).ready(function(){
          $("#username").click(function(){
               //your code here
          });
     });
</script>
     </head>


为什么要结合js和php。什么是$this->load->library('javascript')$这个->加载->库('javascript/jquery')@Rakeshharma,从我这里得到的。当我使用$this->load->library('jquery');这是我遇到的错误,无法加载请求的类jquery在CodeIgniterTanks中有任何方法可以使用jquery,但无法使用..我可以包括jquery.1.8.3.js并编写代码吗。我试过了,但没用..有没有办法在chrome devTools中使用jquerycheck控制台,当我使用base_url时,告诉我结果,会得到一个空白页面。你在config中设置$config['base_url']的值?如果不将其设置为“像这样是,$config['base\u url']=”;在这样的视图页面中,