Cleef
Cleef

Reputation: 23

Why won't jquery run on my local machine?

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

Upvotes: 2

Views: 2865

Answers (4)

Patrick Aleman
Patrick Aleman

Reputation: 619

<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.

Upvotes: 1

Blender
Blender

Reputation: 298176

// 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.

Upvotes: 4

griegs
griegs

Reputation: 22760

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

Upvotes: 0

Nikolay Kostov
Nikolay Kostov

Reputation: 16963

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"> 

Upvotes: 2

Related Questions