Hello, 
I tried to check the example from the api Google Translate page on my 
domain (from referer restriction), I put this simple code, from google docs:

<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Translate API Example</title>
  </head>
  <body>
    <div id="sourceText">Hello world</div>
    <div id="translation"></div>
    <script>
      function translateText(response) {
        document.getElementById("
translation").innerHTML += "<br>" + 
response.data.translations[0].translatedText;
      }
    </script>
    <script>
      var newScript = document.createElement('script');
      newScript.type = 'text/javascript';
      var sourceText = 
escape(document.getElementById("sourceText").innerHTML);
      // WARNING: be aware that YOUR-API-KEY inside html is viewable by all 
your users.
      // Restrict your key to designated domains or use a proxy to hide 
your key
      // to avoid misuage by other party.
      var source = '
https://www.googleapis.com/language/translate/v2?key=*******&source=en&target=de&callback=translateText&q=<https://www.googleapis.com/language/translate/v2?key=AIzaSyBTiDt3z0xVZd52E6FbPO_fMjs0j6i_0cM&source=en&target=de&callback=translateText&q=>'
 
+ sourceText;
      newScript.src = source;

      // When we add this script to the head, the request is sent off.
      document.getElementsByTagName('head')[0].appendChild(newScript);
    </script>
  </body>
  </html>


But I received na error in firebug:

TypeError: response.data is undefined

...lementById("translation").innerHTML += "<br>" + 
response.data.translations[0].tr...


I don't really know. What is wrong ?

Could you help me?

I will appreciate it.

Marcin

-- 
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]
To view this message on the web, visit
https://groups.google.com/d/msg/google-ajax-search-api/-/SvXl3Q8hbEEJ
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

Reply via email to