Jump to content

Recommended Posts

Posted

hi guys, please i need your help in figuring out why my machine isn't loading googles cdn. i suspect its a path issue but i am unable to detect what is actually wrong.

 

here is my code snippet

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>getting jquery</title>

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

<script type="text/javascript">

google.load("jquery", "1.8.1");

google.setOnLoadCallback(function()

{

console.log($('#title').text());

});

</script>

</head>

<body>

<h1 id="title">Getting jquery</h1>

</body>

</html>

 

 

but i get an error saying : "ReferenceError: google is not defined" in my console log.

 

any help would be appreciated

 

 

thanks

Posted

Don't you need a "http:" on the link: "//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"?

 

well, thought so too. but even adding that, the error still comes up in console log.

Posted

Well, you definitely do need to include the http, but I'm a little confused... the link you are linking to is the jQuery file -- you shouldn't need to do any google.load(). Are you following any specific tutorial?

 

 

yes i am following the 'complete web programmer' purchased from killerphp. the original link shown in the tutorial referred to use --> src = "http://ajax.googleapis.com/jsapi" but that isnt working either.

 

i could easily insert my downloaded jquery file in the 'src' and my script would work fine but as adviced in the tutorial, its best to use google cdn to access jquery and im finding it impossible to get it to work.

Posted

As far as I understand it, Google's CDN has changed since that tutorial was written (I'm actually in the process of redoing some of the jquery videos). As far as I understand it, Google's CDN just uses a direct link to the javascript file now. See https://developers.google.com/speed/libraries/devguide#jquery

 

you are right, i figured it was not current. i did see this link already but for some reason it isn't connecting. thanks for your replies though...really appreciate them.

Posted

you are right, i figured it was not current. i did see this link already but for some reason it isn't connecting. thanks for your replies though...really appreciate them.

Make sure you add the "http:" portion? I'm not sure why the examples on the Google page don't have them, but you definitely need that.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...