0

I am beating my head against the wall on this. I know Javascript/jQuery well and I can not see the reason why this is not working. I've tried both 2.0.3 and 1.10.2 with the same results.

I'm trying to just do a test to make sure the script file is loaded. I've tried a number of different methods, nothing is working. But when I click the url in the source, it goes to the correct file that has the right code.

This is all I'm trying to do.

$(document).ready(function() {
   alert('test');
});

Which works if I include it in the page between <script> tags. But not when referencing it from a .js file.

This is how I'm loading it:

<script type="text/javscript"
        src="http://localhost/kdev/views/dashboard/js/default.js"></script>

Clicking on that url takes me to the correct file with the alert above.

But's not working. What the crap is going on? What did I forget? Do I have a typo?

The entire page:

<!doctype html>
<html>
<head>
   <title>Test</title>
   <link rel="stylesheet" href="http://localhost/kdev/public/css/default.css" />
   <script type="text/javscript" 
           src="http://localhost/kdev/public/js/jquery-2.0.3.min.js"></script>
   <script type="text/javscript"
           src="http://localhost/kdev/views/dashboard/js/default.js"></script>
</head>
<body>   
<div id="header">
    header
    <br />
    <a href="http://localhost/kdev/index">Index</a>
    <a href="http://localhost/kdev/help">help</a>
               <a href="http://localhost/kdev/dashboard/logout">logout</a>
        </div>

 <div id="content">
 Dashboard... logged in only    </div>
 <div id="footer">feet</div>
</body>
</html>
4
  • Did you had a look in both requests loading the js files? Commented Oct 6, 2013 at 21:42
  • 1
    type="text/javscript" --> type="text/javascript" Commented Oct 6, 2013 at 21:43
  • 1
    type="text/javscript" ?? ;) Commented Oct 6, 2013 at 21:43
  • 3
    if using <!DOCTYPE html> , just <script src="file.js"></script> is cool too Commented Oct 6, 2013 at 21:44

2 Answers 2

6

Change this (You missed 'a' char in 'javascript')

 <script type="text/javscript"
        src="http://localhost/kdev/views/dashboard/js/default.js"></script>

to this:

<script type="text/javascript"
        src="http://localhost/kdev/views/dashboard/js/default.js"></script>
Sign up to request clarification or add additional context in comments.

2 Comments

..........jQuery was loading fine. Like I said, the function worked fine in the page. Ty so much. I knew it was something stupid.
In HTML5, you don't even need the type attribute. It's unnecesary and only causes trouble.
0

My lightbox script file wasn't loeading properly:

<script type="text/javascript" src="js/lightbox-plus-jquery.min.js"></script>

I then removed type="text/javascript" and it loaded perfectly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.