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=' + 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
google-ajax...@googlegroups.com
To unsubscribe from this group, send email to
google-ajax-searc...@googlegroups.com
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
1. Uncaught TypeError: Cannot read property 'translations' of undefined attivita.asp?clien=7460C&reset=1:428
1. translateText1attivita.asp?clien=7460C&reset=1:428
2. (anonymous function)
// API callback
translateText1({
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
);
--
--
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
google-ajax...@googlegroups.com
To unsubscribe from this group, send email to
To view this message on the web, visit
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-ajax-searc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.