In the below code, I want the translation to be stored in var temp!
but it never does. And I always have to end up using div / span tags
and filling them using container.innerHTML
var temp;
var toTranslate = "Hello World!";
google.language.translate(toTranslate, "en", "fr", function(result)
{
if (!result.error)
{
var container = document.getElementById("s1");
container.innerHTML = result.translation;
temp = result.translation;
alert(temp); // here, temp has the translation, but this is called
after the below "alert" call
}
});
alert(temp); // here, temp = undefined
How do I get this to work?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---