我在用Ajax通过 jQuery,我正在尝试使用谷歌翻译服务。该服务似乎不适合我。
我究竟做错了什么?我将如何在我的网络应用程序中使用它?
你可以这样做:
$.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);
}
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)