Using Javascript alone, there is really no way to run translation requests 
"synchronously," or in such a manner that the browser runs the translation and 
waits to continue executing script until a response is received. That said, you 
can work around this by building your own server-side proxy. Once you've built 
this proxy, you can set up an XMLHttpRequest in synchronous mode to send 
requests back to the server, which will send the request to Google and return 
the response back to your script. You will then have to parse it with either an 
eval (not a great idea) or the json2.js parser from http://www.json.org.

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

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

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

On Sep 15, 2010, at 8:49 PM, Eureka wrote:

> Hi!
> 
> i'm making a js script for retranslating some times an array. It's
> quite funny if you read the text retranslated a few times and I wanted
> to do it automatically with a script but while i was trying this i
> "get" an error. My code is ok because i get the answer if I save all
> to a var and the I call setTimeout to a function that prints that var
> but it's not good idea because js gets crazy because it sends to
> google the request but continues with the rest of the loop and if i
> want to include something more between the diferent translations I
> can't. I don't want to continue before I get the answer from Google
> so, how can I stop js loop until I get an answer from Google?
> 
> Thanks!
> 
> -- 
> 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.
> 

-- 
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