nini3008 Posted September 23, 2012 Report Share Posted September 23, 2012 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 Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 23, 2012 Report Share Posted September 23, 2012 Don't you need a "http:" on the link: "//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"? Quote Link to comment Share on other sites More sharing options...
nini3008 Posted September 23, 2012 Author Report Share Posted September 23, 2012 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 23, 2012 Report Share Posted September 23, 2012 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? Quote Link to comment Share on other sites More sharing options...
nini3008 Posted September 24, 2012 Author Report Share Posted September 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 24, 2012 Report Share Posted September 24, 2012 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 Quote Link to comment Share on other sites More sharing options...
nini3008 Posted September 24, 2012 Author Report Share Posted September 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 25, 2012 Report Share Posted September 25, 2012 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.