In my config file I have $config['jque开发者_如何学编程ry'] = 'js/jquery.js';
My jquery.js
file resides outside of the application folder, and is inside the js folder
In my controller I have
public $jquery
public function __construct(){
$this->jquery = $this->config->item('jquery');
}
public function index(){
$data['jquery'] = $this->jquery;
$this->load->view('site_view',$data);
}
In my view file I have
<script type="text/javascript" src='<?php echo "$base/$jquery" ;?>'></script>
Now the question is,
When I do some basic jQuery scripts why does it not work? I tried adding an externaljs.js
file which contains a very basic jquery script for checking a box and disabling a button.
It doesn't work unless I use vanilla javascript in the view file itself.
I don't know what's going on, I even included the js folder at the htaccess
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
Anyone knows what is happening? In other frameworks I never had problems including jquery at all.
Look at your source,
You are using an absolute path instead of a valid http://
path try using site_url like so
<?php echo site_url($jquery);?>
Note that this assumes your setup looks something like
/
/Application
/System
/Css
/js
/index.php
/.htaccess
精彩评论