0

I am having difficulty getting jQuery to load at all. I'm writing prototype in notepad++ and using Coffee Cup to rebuild my old site.

After googling multiple forums and correcting multiple items, I end up with good code that just won't load. I checked out "6 Things to Do When jQuery Doesn't Work." My script tag at the beginning has <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery1.9.1/jquery.min.js">

Here is what I've tried so far:

  • W3schools
  • Forays into your forum questions on the load() function.
  • Setting it up in jsfiddle.net. It passes the script itself but there is no result.
  • Logging into my sysadmin account on my local machine in case there is some administrative prohibition against deploying script. I will try local group policy.
  • Checking my Norton 360 software for script interception.
  • Doing a script with plain Javascript. It works.
  • Checking all browsers to make sure Javascript is enabled. It is.

Here is my code. The jQuery is a plain css function that will color all the div boundaries red. I'm writing in css3 and html5. I included all the meta stuff under the doctype in case that is interfering. Also, even though html5 doesn't need text=javascript, Firefox seems to want this. Also, there is an opening script tag. Just won't display.

    <script (see google source above)>
        $(document).ready(function(){
            $("div").css("border", "3px solid red");
        });
    </script>
</head>
<body>
    <div id="shalom">Shalom</div>
    <div id="wrapper"> 
        <p>"LoremLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do </p>
    </div>
    <div> 
        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi</p>  
    </div> 
</body>
</html>
Matt Ball
  • 354,903
  • 100
  • 647
  • 710

3 Answers3

8

An HTML validator will tell you that you can't combine script tags with src and content. Separate them, like below, and make sure the script tags are property closed, and that the URL to jQuery is correct (the one in your question 404s):

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>
$(document).ready(function(){
    $("div").css("border", "3px solid red");
});
</script>

Further, note that scheme-relative URLs (the ones that start with //) won't work if you're just opening a local HTML file, since that uses the file:// scheme.

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
  • Thanks for the prompt responses. I did separate the src and content. I sent the google link to my son the head programmer, and he said it loaded from his machine. However, it still did not load. It turns out that my antivirus software (Norton 360) was not letting googles jquery source load. I got some more help and found that accessing the jquery .com site's source did work: "src="http://code.jquery.com/jquery-latest.min.js"". My best guess at this time is that it was a certificate issue. I'm not sure, since I can't change Norton's settings locally. – Gershon Blackmore Mar 13 '13 at 21:30
2

The script src for the jQuery library, which you're using, doesn't seem to be valid. Try this: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

Frederick Andersen
  • 304
  • 1
  • 6
  • 18
  • Thanks, I tried loading this into the browser window and didn't get 404'd like with the other one. I'll have to compare them side by side to see what the difference is.... Gershon – Gershon Blackmore Mar 13 '13 at 21:36
1

You can't put additional code inside a <script> tag that's got a "src" attribute to load another script. You just need an additional <script> after that one where your code will reside.

Pointy
  • 405,095
  • 59
  • 585
  • 614
  • Thanks. I'm amazed at how many people responded with this comment. As it turns out, there was a misplaced backslash in my google link which caused it to 404. Strange, because I copied it right out of W3schools' site. – Gershon Blackmore Mar 13 '13 at 21:41
  • @GershonBlackmore w3schools is hardly the best reference to use. – Matt Ball Mar 13 '13 at 21:45