Welcome Guest, Not a member yet? Register   Sign In
Add a .js file and routes
#5

Thanks all for your answers.

@kenjis : no, I use HTML for more than 20 years, I know what is an absolute or relative link, thanks.
@InsiteFX : I've found that everything is redirected to the "public" folder, I guess it's the default configuration in the main htaccess.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ public/$1 [L]

So I tried <script src="menu.js"></script> and it worked finally !! The menu.js should be in the "public" folder.
Note that <script src="<?= base_URL('menu.js'); ?>"></script> doesn't work : error 404 not found (which is logical because menu.js is not in the root of my project)
and <script src="<?= base_URL('public/menu.js'); ?>"></script> doesn't work either : error 404, the same that I got, which is frustrating because the full link is OK but error 404.
Exactly the same for <script src="<?= base_url()."public/menu.js" ?>"></script>, same (theoretically good) link, same error.

Another time, in Config, my App.php is well set for "public string $baseURL" which is of course important.

So I will finally create a js folder in my public folder, and use <script src="js/menu.js"></script>. I guess that my .js will be public but I guess that all js are always public because loaded by the client browser, isn't it ?

Coding is so frustrating sometimes... Thanks everyone.
Reply


Messages In This Thread
Add a .js file and routes - by arna - 08-10-2023, 06:58 PM
RE: Add a .js file and routes - by kenjis - 08-10-2023, 07:18 PM
RE: Add a .js file and routes - by ozornick - 08-10-2023, 10:36 PM
RE: Add a .js file and routes - by InsiteFX - 08-10-2023, 10:41 PM
RE: Add a .js file and routes - by arna - 08-11-2023, 07:30 AM
RE: Add a .js file and routes - by kenjis - 08-11-2023, 06:23 PM
RE: Add a .js file and routes - by sheilaf - 08-11-2023, 10:19 AM
RE: Add a .js file and routes - by arna - 08-11-2023, 11:02 AM
RE: Add a .js file and routes - by arna - 08-11-2023, 07:03 PM
RE: Add a .js file and routes - by ozornick - 08-11-2023, 08:40 PM
RE: Add a .js file and routes - by arna - 08-11-2023, 09:20 PM
RE: Add a .js file and routes - by InsiteFX - 08-11-2023, 10:39 PM
RE: Add a .js file and routes - by ozornick - 08-12-2023, 12:50 AM
RE: Add a .js file and routes - by kenjis - 08-12-2023, 02:45 AM
RE: Add a .js file and routes - by arna - 08-12-2023, 04:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB