That's okay. We used to support the Translate API over here and, in fact,
are still happy to do so as we can. At any rate, the problem is that JSONP
does not do POST requests. Instead of using a XMLHttpRequest, where you can
control headers and request method, it uses a script tag, where you can
only send information via GET. To do what you're wanting to do, you're
going to need to build a proxy on your own domain/server using PHP, Perl,
or some other server-side language. That way you can use an XMLHttpRequest
to send the data via POST to your server, which will relay the request to
Google's server and then return Google's response to your application.

Don't forget to tell them over in the Translate API forum that we provided
the answer :D

jg

On Sat, Apr 6, 2013 at 6:55 PM, Andrew Beaven <[email protected]> wrote:

> Sorry, wrong forum. Reposted in
> https://groups.google.com/forum/#!topic/google-translate-api/vFfr7lhWz1M
>
>
> On Sunday, April 7, 2013 2:34:04 AM UTC+13, Andrew Beaven wrote:
>>
>> Hi there,
>>
>> I'm trying to call the Google Translate API using ajax like so:
>>
>> var Utils = {
>>>     translate: function(message, callback) {
>>>         $.ajax({
>>>             type: 'POST',
>>>             url: 
>>> 'https://www.googleapis.com/**language/translate/v2<https://www.googleapis.com/language/translate/v2>
>>> ',
>>>             headers: { "X-HTTP-Method-Override": "GET" },
>>>             dataType: 'jsonp',
>>>             data: {
>>>                 key: '<my key here>',
>>>                 source: 'en',
>>>                 target: 'ru',
>>>                 q: message
>>>             },
>>>             success: callback
>>>         });
>>>     }
>>> }
>>
>>
>> I'm finding that when the message is too large, I get a 414 error,
>> indicating that the request URL is too large - it looks like the message
>> is concatenated onto the request URL. I'm confused by this because I had
>> thought that data sent in POST ajax requests were not sent via parameters
>> in the URL. The translate docs mention if you want to sent lots of data, to
>> do so via a POST, so I thought I'd be fine
>>
>> Is there anything I'm doing wrong here?
>>
>  --
> --
> 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/-/XfBD35OP1m4J
>
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan
Church!
http://www.debraheightswesleyan.org

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to