我正在尝试从当前版本的 MS Bing Translator 转换为新的 Azure 版本。
我按照新文档中的描述创建了一个访问令牌,尽管 Microsoft 提供的以下示例(针对 Azure)可以正常工作:
function translate() {
var from = "en", to = "es", text = "hello world";
var s = document.createElement("script");
s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate" +
"?appId=" + settings.appID +
"&from=" + encodeURIComponent(from) +
"&to=" + encodeURIComponent(to) +
"&text=" + encodeURIComponent(text) +
"&oncomplete=mycallback";
document.body.appendChild(s);
}
function mycallback(response) {
alert(response);
}
我想将上面的代码转换为 jQuery 调用。
我从以前的版本中修改了一个类似的 jQuery ajax 调用,它有效,但是parseerror-jQuery17206897480448242277_1343343577741 was not called
发出了:
function jqueryTranslate() {
var p = {};
p.appid = settings.appID;
p.to = "es";
p.from = "en";
p.text = "Goodbye Cruel World";
p.contentType = 'text/html';
$.ajax({
url: 'http://api.microsofttranslator.com/V2/Ajax.svc/Translate',
data: p,
dataType: 'jsonp',
jsonp: 'oncomplete',
complete: function (request, status) {
},
success: function (result, status) {
alert(result);
},
error: function (a, b, c) {
alert(b + '-' + c);
}
});
}
我非常感谢和理解出了什么问题,所以 TIA 为您提供时间。