2

I want to load jQuery from Google, but it always fails to load. What is wrong in my source code?

Mistake

(X) GET file://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js  

CODE

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta content='IE=8' http-equiv='X-UA-Compatible'>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" type="text/css" href="">
    <title></title> 
</head>
<body>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>console.log($('body').height());</script>
</body>
</html>
3
  • What country are you in? Commented Jan 22, 2014 at 19:55
  • 2
    To the people who voted to close: this is a perfectly reproducible issue and it is not a typographical error, this is a common issue and source of confusion with protocol relative URLs and local development. Don't vote to close questions if you don't understand enough about what you are reading to make that call. Commented Jan 22, 2014 at 20:06
  • 1
    @Ennui You said it. This question is perfectly within SO Rules/Guidelines. Commented Jan 22, 2014 at 20:09

1 Answer 1

8

This is because you are testing the file locally.

Change

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>

To

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>

Add comment @Ennui

To explain, // is a protocol relative url, so on localhost it will be interpreted as file://, on http as http:// and over SSL as https://. This is useful on sites that combine http and https protocols, but can get confusing when used on a local development site.

Sign up to request clarification or add additional context in comments.

1 Comment

To explain, // is a protocol relative url, so on localhost it will be interpreted as file://, on http as http:// and over SSL as https://. This is useful on sites that combine http and https protocols, but can get confusing when used on a local development site.

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.