Welcome Guest, Not a member yet? Register   Sign In
Can't load external javascript code

I'm trying to load an external javascript code inside a view from my project, but the browser can't find.

The javascript is found on: localhost/diceroller/assets/js/script.js
My index.php is found on: localhost/diceroller

The load external javascript code is in my view:
<script src='<?php echo base_url("assets/js/script.js"); ?>' type='text/javascript' ></script>

On Firefox, when I press F12 I found on console that say the following:

Falha no carregamento do <script> com a fonte “http://localhost:8080/diceroller/assets/js/script.js”
(Failed to load <script> with source "http://localhost:8080/diceroller/assets/js/script.js")

As you can see, the script.js is on localhost/diceroller/assets/js/ but the browser can't find on that folder.

It states localhost:8080/diceroller/assets/js/script.js and not localhost/diceroller/assets/js/script.js so you need to make sure that's the correct url.

app.baseURL in .env if you have changed from the default url.

(This post was last modified: 04-30-2020, 02:31 PM by danielsonsilva.)

I changed the $baseURL inside Config/App.php to "http://localhost/diceroller/", restarted the xampp and did try again.
But the message only crop the 8080 from the message:

Falha no carregamento do <script> com a fonte “http://localhost/diceroller/assets/js/script.js”.
Failed in load the <script> with source “http://localhost/diceroller/assets/js/script.js”

Can you take a screenshot of the contents of diceroller?

Hello, there is a print-screen from the project on the view/diceroller.php open to show the line that I load de file script.js and the browser could not find it.

Attached Files Thumbnail(s)

To me it looks like index.php are inside assets folder. Hard to tell how those arrow points... Does your CSS load?

(This post was last modified: 05-04-2020, 05:38 AM by danielsonsilva.)

The CSS doesn't load also.
I put some lines in the picture to become easy to follow the directories.

Attached Files Thumbnail(s)

(This post was last modified: 05-04-2020, 11:08 AM by jreklund.)

Okay, still some odd looking indention. xD

So you get the CI Welcome message at: localhost/diceroller?

Try moving around your CSS file to see where it's actually at. Start putting it in the root folder (localhost) and work from there. Can't really help you any further, as it's not physically there according to your sever. The only thing I can thing of are that you have incorrect permissions on that folder.

I'll try that today.
Move the file around to see if the browser check its contents.

It was missing the project name into base app directory into Config/App.php.
It have to be looking into localhost/professionalsite/diceroller instead of localhost/diceroller.

Theme © iAndrew 2016 - Forum software by © MyBB