<script src="<?php echo site_url('bootstrapper/jqTimer'); ?>"></script>
So I’ve tried to call the controller below using the script above but I get error not found. Any ideas as to why this method is not working?
function jqTimer() {
$this->load->view("jquery.timers.js");
}
When loading javascript with a
<script>tag, thesrcattribute is expecting a file name to a js file. You’re giving it a path to a controller method in your CI install.What you need to do is put the
jquery.timers.jsfile in thepublic_htmlfolder and access it from there:If you’d prefer to load your javascript through views, then you need to do this instead:
This will echo out the contents of the view file between the
<script>tags for embedded javascript. (passingTRUEas the third parameter returns the content of the file, so you can echo it out)