To load external Javascript file in codeignitor, I'm using
<script src="<?php echo base_url("application/js/contentslider.js"); ?>" type="text/javascript"></script>
I can see in the page's source as
<script src="http://localhost/cinifb_ci/application/js/contentslider.js" type="text/javascript"></script>
which means to my knowledge that the file is loading perfectly similarly for my CSS file, I've used
<link rel="stylesheet" href="<?php echo base_url(); ?>application/css/default.css" type="text/css" />
and in the page's source code its showing as
<link rel="stylesheet" href="http://localhost/cinifb_ci/application/css/default.css" type="text/css" />
which means even its loading perfectly. (on clicking the external js/css link in the source its showing 403 Forbidden
). But neither of their effects are applied on the page. No error its showing.
I've loaded URL helper in controller as $this->load->helper('url');
and placed $autoload['helper'] = array('url');
in autoload.php
can you please explain me where I went wrong.
I learn that to load external JS, we need to install jquery-codeigniter library. I've downloaded them and included the respective files into respective similar folders of my application folder.
Now when I try to include $this->load->library('jquery');
in my controller, its showing
An Error Was Encountered
Unable to load the requested class: jquery
Hence I request you to please help me to understand why 403 Forbidden is showing when I can see its pointing to the exact location of the JS/CSS file and secondly if the installation of the jquery-codeigniter library is wrong please guide me.
Note: http://ellislab.com/codeigniter/user-guide/libraries/javascript.html didn't help me
Edit:
jquery-codeigniter library i've placed in system/libraries/javascript/
In systems .htaccess file, I've written as
RewriteEngine on
RewriteRule ^$ /index.php [L]
RewriteCond $1 !^(index\.php|images|css|js|video_files|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /cinifb_ci/index.php/$1 [L]
In the view I'm writing as
$this->load->helper('url');
<script src="<?php echo base_url("application/js/jquery-1.8.2.js"); ?>" type="text/javascript"></script>
In controller as
$this->load->helper('url');
$this->load->library('javascript');
$this->load->library('javascript/jquery');
$this->load->library('Jquery_ext');
again if I look at source its pointing to correct source but still if i click external js file link, its showing 403 Forbidden
error
Sorry for lengthy post 🙁
Suggestions please ..!
Best Answer
A 403 hidden error means that the Web Server is rejecting the request to that particular resource.
I am going to assume you are using the provided .htaccess file to get pretty urls.
In the line that
Make it read
Actually, the above could be wrong, regardless, the idea is there that you need to add your css and js folders to the
RewriteCond
exception list