Looking at a code snippet, it's tough to know for sure, but I'm  
wondering if languages is supposed to be google.language.Languages.   
If that's the case, then the loop is never running because it  
languages has no properties.  Otherwise, if you could provide a link,  
it may help us to see what's going on.

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

For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
[email protected]

Unless otherwise noted, any price quotes contained within this  
communication are given in US dollars.

If you're in the Des Moines, IA, area, check out Debra Heights  
Wesleyan Church!

And check out my blog, Adventures in Web Development, at 
http://jgeerdes.blogspot.com 
  !


On Mar 24, 2009, at 5:38 PM, John Bautista wrote:

>
> Good morning!
>
> I'm having a problem with google's callback functions. I'm a newbie in
> Javascript so I really don't understand what's happening with the
> code. I can't access a global and function local variables inside a
> google callback function. Example
>
> function translateWords(words,choice){
>
>               var lang = "";
>               for(var l in languages){
>                       if(l == choice) lang = languages[l];
>               }
>
>               google.language.translate(words, "en", lang, function(result) {
>                       if (!result.error) {
>                               var container = 
> document.getElementById("translation");
>                               container.innerHTML = words + lang + 
> result.translation; /**/
>                       }
>               });
>
>       }
>
> in the line /**/, the variable 'words' can be accessed, but 'lang'
> can't. I don't know why it is happening. I tried defining 'lang' as a
> global variable but to no avail. And when I can't put value to a
> global/function local variable inside the callback. How should I do
> that? Thank you very much!
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to