English 中文(简体)
Google Translate call from JS using POST
原标题:

We re using google translate to translate some shorter texts dynamically on our site. The current implementation looks pretty much like this example in google code playground.

Now we need to translate slightly longer texts, which are too long for GET-method. From google documentation it seems to be possible to use POST for sending the translation string.

Can anybody explain how to get it to use POST as there is no form that s submitted and the data sent to google contains only text and source/target languages?

Thanks in advance.

最佳回答

As it says in the documentation, it is not possible with JavaScript. But what you can do is create a webservice in between Google and you in a server side language. And then use JavaScript to run parameter to the.

alt text

(http://bildr.no/view/551563)

问题回答

To answer my own question: It seems it s impossible to get the JS translator call to use POST. The workaround would be to send(ajax) the translation-string to our server, make the server connect to Google, get the translation, send(ajax) it back to client and update it.

The other evident option is to clip to text to small enough chunks to fit GET...





相关问题
Programmatic HTML POST with C#.NET 1.1

I m trying to integrate the Moneris Hosted Pay Page into my .net 1.1 app with an iFrame. I ve done this many times before, but not with .net 1.1. I can t seem to find a good resource for doing a ...

Receive POST from External Form

I have a form on another website (using a different backend) that I want to be able to POST to my Rails application (on a different domain). How do I generate a valid authenticity token for the ...

Getting posted values in MVC PartialView

I ve created a PartialView which I render with Html.RenderPartial, passing the name of the view and the strongly-typed data item to bind to (below): <% Html.RenderPartial("...

Create new etherpad using PHP and CURL

I m trying to write a simple PHP script which automatically sets up new etherpads (see http://etherpad.com/). They don t have an API (yet) for creating new pads so I m trying to figure if I can do ...

How to get unselected checkbox?

I have three checkboxes like ch[0], ch[1] and ch[3] (sometimes i have more, or less, it s dinamic) and in PHP i want to get the unselected items also, like this: 0=yes,1=no,3=yes and so on. Can I ...

热门标签