How can you pass additional arguments to the callback method? The answer is a
method callback. Essentially, this is a function that returns a function. So,
something like this should work well for what you're wanting:
function createClosure(arg1, arg2, arg3...){
return function(response){
translateText(response, arg1, arg2, arg3...)
}
}
How many characters can you pass to the q parameter? It varies, depending on
how many characters require URL encoding. MSIE (at least older versions) has a
limit on the total length of a URL it will support, which is right about 2048
characters. In addition, Google's servers have implemented a similar limit,
cutting off at about 2000 characters. You can, however, submit a longer URL via
the POST method. The challenge for doing this in Javascript, of course, is that
you can't do it via JSONP, and you can't do it (reliably, cross-platform) by an
XMLHttpRequest. What you can do, though, is build a simple server-side proxy
which you can load on your own server. Then you can build an XMLHttpRequest to
send the query back to your server via POST. Your server will then relay the
request to Google, again via POST. And when the response is returned, your
server will relay it back to the client.
If all of this sounds a bit crazy, you might be interested in the
gtranslate-api-v2-jsapi project on Google Code. It provides a Javascript
wrapper which approximates the functionality of the official v1 Javascript
Translate API. But it also includes a PHP proxy application. The Javascript
automatically detects the length of the query string and switches to the proxy
when the string gets too long. You can find the project at
http://code.google.com/p/gtranslate-api-v2-jsapi .
Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA
For more information or a project quote:
[email protected]
If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!
On Dec 6, 2011, at 6:12 AM, riz4uall wrote:
> also i want to know maximum number or characters i can pass in q={}
>
> i tried passing 2048 characters but it gives me error : 414 Request-
> URI Too Large
>
> --
> 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
> http://groups.google.com/group/google-ajax-search-api?hl=en_US
> 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 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
http://groups.google.com/group/google-ajax-search-api?hl=en_US
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en