This is because if you exceed the URL length limit that Google has  
imposed on all of its services as a security precaution, rather than  
returning Javascript which would ultimately trigger your callback, the  
servers instead respond with a standard error message saying that the  
request URI was too long. What I would do is use Firebug to examine  
the net requests, subtract the number of characters in the request uri  
(not including the query string) from 2,000 (i.e., the uri length  
limit), and test the length of your query string (be sure to uri  
encode it first!) against that remainder. Then you'll know if your url  
will be too long before you ever make the request.

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

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

Unless otherwise noted, any price quotes contained within this  
communication are given in US dollars.

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

And check out my blog, Adventures in Web Development, at 
http://jgeerdes.blogspot.com 
  !


On Dec 8, 2009, at 9:20 PM, Mike Duffy wrote:

> <html lang="en"><head><title>Test</title>
> <script type="text/javascript" src="http://www.google.com/jsapi";></
> script>
> <script type="text/javascript">
>
> // (My API developer key removed above.)
>
> // Greetings, all. Originally, I posted this on
> //
> // http://groups.google.com/group/google-translate?pli=1 ,
> //
> // But I was told that THIS group is better for all API questions, so
> I have copied it here.
>
> // Here is a simple script to demonstrate the problem.
> // Basically, it just looks at the body section for
> // segments identified by span tags with values
> // t0 t1 t2 ... until it does not find any more.
> // (In the supplied example these 3 are the only ones.)
> //
> // If you want to try it yourself, just extract the entire post
> // into a file of type ".htm" and then double-click on it.
> //
> // In order to "prove" that errors from the API are correctly
> // handled, in function translateTest() I specifically use an
> // illegal destination language of "xx" for span "t1".
> //
> // The problem I am demonstrating is that when the text to translate
> // is too large, the callback function is NEVER executed.
> //
> // I notice that this limit is mentioned elsewhere, but it seems
> // that for the other APIs (maps, search, etc.) you get an error.
> //
> // For sure, there needs to be some limit on the size. What I
> // am asking is that when a request exceeds this value,
> // the callback function should return an error message,
> // not "hang up".
> //
>
> google.load("language", "1");
>
>
> function logMessage(message)
>  {var dtext = document.forms.debug.debugtext.value;
>  document.forms.debug.debugtext.value = dtext + message + '\n';
> return;}
>
>
> function translateTest()
>  {document.forms.debug.debugtext.value = "Starting up!\n";
>  spanNumber = 0;
>  while(document.getElementById("t" + spanNumber))
>    {tag = "t" + spanNumber;
>    logMessage("Requesting:" + tag + ", " + document.getElementById
> ("t" + spanNumber).innerHTML.length + " bytes.");
>    tLang = 'fr'; if (tag == 't1') tLang='xx';
>    translateOne(tag, tLang);
>    spanNumber++;
>    };
>  }
>
>
> function translateOne(spantag, lang)
>  {
>  var englishSpan = document.getElementById(spantag).innerHTML;
>  google.language.translate
>    (englishSpan, 'en', lang, function(result)
>      {
>      if (result.translation)
>        {
>        var outText = result.translation;
>        logMessage("Success with :"+spantag);
>        document.getElementById(spantag).innerHTML = outText;
>        }
>      else
>        {
>        var errorMessage = 'Err#' + result.error.code + '!';
>        logMessage("Failure with :"+spantag + ",  " + errorMessage);
>        };
>      return;
>      }
>    );
>  }
> </script>
>
>
> </head>
>
>
> <body>
>
>
> Click <a href="#" onclick="translateTest(); return false;">Here</a>
> to
> perform test.
>
>
> <p><span id="t0">0 This text should be okay!</span></p>
>
>
> <p><span id="t1">1 Should give an error (bad language)</span></p>
>
>
> <p><span id="t2">2 Dummy text in untranslateable span. Dummy text in
> untranslateable span. Dummy text in untranslateable span. Dummy text
> in untranslateable span. Dummy text in untranslateable span. Dummy
> text in untranslateable span. Dummy text in untranslateable span.
> Dummy text in untranslateable span. Dummy text in untranslateable
> span. Dummy text in untranslateable span. Dummy text in
> untranslateable span. Dummy text in untranslateable span. Dummy text
> in untranslateable span. Dummy text in untranslateable span. Dummy
> text in untranslateable span. Dummy text in untranslateable span.
> Dummy text in untranslateable span. Dummy text in untranslateable
> span. Dummy text in untranslateable span. Dummy text in
> untranslateable span. Dummy text in untranslateable span. Dummy text
> in untranslateable span. Dummy text in untranslateable span. Dummy
> text in untranslateable span. Dummy text in untranslateable span.
> Dummy text in untranslateable span. Dummy text in untranslateable
> span. Dummy text in untranslateable span. Dummy text in
> untranslateable span. Dummy text in untranslateable span. Dummy text
> in untranslateable span. Dummy text in untranslateable span. Dummy
> text in untranslateable span. Dummy text in untranslateable span.
> Dummy text in untranslateable span. Dummy text in untranslateable
> span. Dummy text in untranslateable span. Dummy text in
> untranslateable span. Dummy text in untranslateable span. Dummy text
> in untranslateable span. Dummy text in untranslateable span. Dummy
> text translate.
> </span></p>
>
>
> <span id="debug"><form name="debug"><textarea name="debugtext"
> title="Debug" rows="10" cols="40" wrap="true" value=""></textarea></
> form></span>
>
>
> </body></html>
>
> --
>
> 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