CodeIgniter and Javascript/Jquery Library

前端 未结 9 872
粉色の甜心
粉色の甜心 2021-02-12 11:51

As title said, I\'m trying to figure out how to use javascript and jquery libraries on CI.

Following instruction in the docs, I load the library in my controller:

9条回答
  •  眼角桃花
    2021-02-12 12:26

    You can try this, it's work to me.
    in config.php

    $config['javascript_location'] = 'http://localhost/ci/js/jquery.min.js';
    

    in Controller

     public function __construct() {
        parent::__construct();
        $this->load->library('javascript');
        $this->load->library('javascript/jquery');
    }
    
     public function index(){
        $d['library_src'] = $this->jquery->script();
        $d['logalert']=$this->jquery->_show('#logalert',1000,"$('#logalert').html('hello world');");
        $this->load->view('main',$d);
     }
    

    in view (head)

    
    

    in view content (body)

    in javascript view

    
    

    happy coding :)

提交回复
热议问题