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',
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 fineIs there anything I'm doing wrong here?
https://groups.google.com/d/msg/google-ajax-search-api/-/XfBD35OP1m4J--
--
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
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.
Awesome, thanks for your help mate. As you may have already guessed, I haven't used JSONP before and don't know much about it. In the google translate docs, there's an example under REST using JavaScript, is this what jquery does under the hood when you specify dataType: 'jsonp' in an ajax call?Anyway, back to the question at hand... I'm thinking that because I will potentially need to translate more than 5K characters at a time, I think I'll go about this a different way, use a GET and if the text is bigger than 2K, I'll do multiple requests to the translate service and join the results back up when they return. Thoughts on this approach?
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-search-api+unsub...@googlegroups.com.
--
Jeremy R. GeerdesGenerally Cool GuyDes Moines, IAIf you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!
--
--
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
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.
Great observations - I have implemented already though didn't think about your 4th point so will need to handle that better. Though my site is a .net app, I'll definitely check out your library :DPart of the reason I didn't look at server side solutions was ignorance - the first examples of the translate API usage I saw we're JS implementations so figured that was all that was available. When I realized that wasn't the case, I checked the docs for the .net library they have linked but it said something about it being deprecated.Thanks for your help Jeremy, it's very much appreciated!Andrew
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 a topic in the Google Groups "Google AJAX APIs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-ajax-search-api/9ZINRax3NRE/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-ajax-searc...@googlegroups.com.
--
--
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
Sorry, I was mistaken - it was the examples of use that say something about being deprecated (linked from here). It's probably just that method, though the docs should still be updated.
To unsubscribe from this group and all its topics, send an email to google-ajax-search-api+unsub...@googlegroups.com.
--
--
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
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 google-ajax-search-api+unsub...@googlegroups.com.
--
--
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