Where is myscript.js stored in your app?
Why can't I include a js file?
Since there isn't a beginners channel I'm posting my question here:
I'm trying to include a js file, but for some reason I can't make it work. After a couple of hours work I've narrowed it down to this:
If I include the JS file through a controller returning a blade view it doesn't work. But If I change the name to test.php and enter the whole path in my browser, it works. Also, if I include the code within the returned view file, it works fine - but when I place it in a js file that I try to include, it stops working.
What's messing with me?
Here are my files which are all placed in the same library (../resources/views):
myscript.js
$('#mydiv').html('BAR');
homeTM.blade.php & test.php (the commented out code works if // is removed):
<!doctype html>
<html lang="da">
<head>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<style>
#mydiv
{
height: 55px;
width: 200px;
background-color: blue;
color: white;
font-size: 25px;
text-align: center;
line-height: 48px;
}
</style>
</head>
<body>
<div id="mydiv">foo</div>
</body>
<script>
//$('#mydiv').html('BAR');
</script>
<script src="myscript.js"></script>
</html>
Thanks in advance :)
Okay, so I located the problem:
When I started with Laravel two months ago, I quickly became annoyed with the /public subdomain in the URL. I found a number of solutions on stackoverflow and went for the easiest and moved index.php & .htacces to the root and changed a few lines of code as instructed in the thread, rather than venture into the abyss of the apache file structure which is completely unknown teritorry for me. So when people write "carefull" in the comments of easy solutions, you should pay attention :)
I moved things back to the default setting and followed a video you linked in another thread @Snapey on setting up my wamp server :) - took me 5 minutes and I'm both a bit embarrased and a little amused with myself that I went for the easiest solution which eventually cost me several hours of frustrating debugging.
Everything works as it should now. Thanks for the patience all :)
Here's the video: https://www.youtube.com/watch?v=PRNe9EnNJOs
Please or to participate in this conversation.