google.load returns undefined

5 views
Skip to first unread message

The_Compiler

unread,
Jul 2, 2008, 7:01:18 AM7/2/08
to Google AJAX API
I am trying to test the Google AJAX Language API. I am using the code
from the examples so there is no custom code whatsoever however I am
getting a google is not defined error (in firefox) when I open the
html with my browser.

sample:
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">
google.load("language", "1");

Do we need some sort of key for this API? If yes could someone provide
a link to where we can get one, because I couldn't find it.

Just to clarify, I was opening the html from my hard disk with my
browsers. I don't know whether I should have it on a web server, for
this to actually work. Any firewall issues I should be aware of?

Ben Lisbakken

unread,
Jul 2, 2008, 11:18:59 AM7/2/08
to Google-AJAX...@googlegroups.com
Which sample are you trying?  Just to be clear, you have changed _none_ of the code?

No, you don't need an API key.  Also, you should be able to open the HTML from your hard drive.  Does the sample you are trying work when you are viewing it from us?

-Ben

The_Compiler

unread,
Jul 3, 2008, 6:38:20 AM7/3/08
to Google AJAX API
To be clear I've changed NOTHING. I'm using the identify example,
where it identifies the language and it comes up with Chinese, and
I've copied and pasted the api load lines above from the example
directly. Yes the sample works when I view it from you.

I then copied the source and pasted to a new htm file, and tried to
open it. Didn't work then.

I thought it was a key thing, but since we don't need an API key then
I'm completely clueless :S

Any other ideas?
> > this to actually work. Any firewall issues I should be aware of?- Hide quoted text -
>
> - Show quoted text -

jgeerdes [AJAX APIs "Guru"]

unread,
Jul 4, 2008, 9:42:23 AM7/4/08
to Google AJAX API
If you've changed absolutely nothing on the entire page, then the
problem is on line 59. Specifically, you need to add http://www.google.com
to the beginning of the jsapi script's src attribute. It works on
Google's server because it's a valid relative path, but on your local
disk, it's probably not. In Firefox, with Firebug and/or Web
Developer extensions installed, you can see the result of this if you
look in the Net tab of Firebug (on the local machine, there will be no
net requests), or using the Web Developer's Information -> View
Javascript option (you'll see that you're trying to load file:///jsapi,
and it's coming back blank).

And actually, this same tidbit will apply to a number, if not all, of
Google's samples. They tell - even encourage - people to copy/paste
their example code, but it's not always clear that you have to make
that one modification to the code.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com

If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!
Reply all
Reply to author
Forward
0 new messages