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