2

The following script will work on jsfiddle (see below) but wont work on my local machine.

http://jsfiddle.net/gFaZn/

<!DOCTYPE HTML>

<html>

<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script type="text/javascript" src="script.js"></script>
<link type="text/css" rel="stylesheet" href="stylesheet.css">

</head>

<body>

<div></div>


</body>

</html>

Can anyone tell me what I am doing wrong?

Thanks

Cleef
  • 23
  • 1
  • 3

4 Answers4

4

// tells the browser to match the current protocol. It's fine if you're on a webserver, as it'll switch to http or https, but you're probably loading the file directly with the browser, so it'll expand to file://.

You need to specify the protocol explicitly:

src="http://...

Better yet, use a local webserver.

Blender
  • 289,723
  • 53
  • 439
  • 496
2

Try replacing

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

with

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> 
Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123
  • For an explanation, see [this answer from Dave Ward](http://stackoverflow.com/questions/4831741/can-i-change-all-my-http-links-to-just#answer-4832046) – showdev Aug 12 '16 at 18:07
1
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> 

Will not be understand running locally. add http:// and try agian. And just for your information, JQuery is just javascript and always runs in your browser. So if something doesnt work while using javascript it is or a programming error or a wrong link to JQuery file. Either way, it wont be javascript it self.

Patrick Aleman
  • 612
  • 6
  • 19
  • Cheers Patrick, I thought that might be the case. I tried both with and without the http:// The other link seemed to sort the issue though. Thanks for your help – Cleef Apr 03 '13 at 23:29
0

your source url doesnt link to anything your machine can see perhaps?

a quick test might be

$(function(){
  alert(9);
});

if you dont see the alert then jQuery is not loaded. Fully qualify the path

griegs
  • 22,624
  • 33
  • 128
  • 205