I am using Ajax via jQuery, and I am trying to translate using the Google Translate Service. The service does not seem to work for me.
What am I doing wrong? How would I
You can do it like this:
$.ajax({
url: 'https://ajax.googleapis.com/ajax/services/language/translate',
dataType: 'jsonp',
data: { q: 'Hello world!', // text to translate
v: '1.0',
langpair: 'en|es' }, // '|es' for auto-detect
success: function(result) {
alert(result.responseData.translatedText);
},
error: function(XMLHttpRequest, errorMsg, errorThrown) {
alert(errorMsg);
}
});