Cannot load javascript file into my view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Cannot load javascript file into my view (/showthread.php?tid=76544) |
Cannot load javascript file into my view - metalyx - 05-23-2020 I want to: <script type="text/javascript" src="<?php echo base_url()?>js/graph.js"></script> But I have this problem: "GET http://localhost/www/js/graph.js net::ERR_ABORTED 404 (Not Found)" But I HAVE the file in this route http://localhost/www/js/graph.js. WTF? Why the js script don't include? Can someone help please? RE: Cannot load javascript file into my view - jreklund - 05-23-2020 If it where in that location it would load. So you DO have an incorrect url. First you need to find the real adress; Just ignore CodeIgniter/PHP for the time being and finding the correct url. Without information about your real directory structure, it may be in this location: http://localhost/js/graph.js RE: Cannot load javascript file into my view - dave friend - 05-23-2020 Can you explain the directory structure of your site please? RE: Cannot load javascript file into my view - InsiteFX - 05-24-2020 This is why we always use an assets folder where index.php is. index.php assets -- css -- js -- img -- images -- plugins etc; Then you can use this to display the it. Code: <script src="<?php echo base_url('assets/js/graph.js'); ?></script> |