我试图将MS Bing Translator的当前版本转换为新的Azure版本。Microsoft Azure Translator AJAX API不能正常工作
我创建接入令牌作为新的文档中,虽然由Microsoft提供下面的例子(为天青)所述正常工作:
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你的时间的理解。
我没有在C#中实现新的访问令牌机制。你提供的第二个链接似乎是一个值得追求的策略。谢谢! – 2012-07-27 16:00:05