【发布时间】:2012-03-27 10:24:06
【问题描述】:
我正在使用 Jquery 尝试从 Open Calais api 获取一些数据,但如果我无法获得有效响应。如果我使用数据类型“脚本”,我会收到“缺少 ; before statement”的错误。如果我使用数据类型“xml”或其他任何内容,我会从 Open Calais 服务器收到 403 错误。
我决定根据Calais forum post 上的最后一个条目尝试“脚本”数据类型
请不要对我的代码进行批评和批评。我边走边靠。
我的代码:
var baseUrl="http://api.opencalais.com/enlighten/calais.asmx/Enlighten";
var licenseID="wt8h3w3pt333eewdwsyuhut6";
var content="In response to a legislative provision in a bill reauthorizing the FAA, the agency has launched a comment period as it selects six test sites to evaluate unmanned aircraft systems. The focus of the proceeding will be determining the location of the test sites along with establishing...";
var PARMS="&contentType=text/xml&outputFormat=xml/rdf"
var PostDatavar = "?licenseID="+licenseID+"&content="+encodeURIComponent(content)+PARMS;
var componentURL=baseUrl+PostDatavar;
function sendIt(sendData){
$.ajax({
url:componentURL,
type: "POST",
dataType:"script",
success:function(data){
alert(data));
console.log(data);
},
error:function(){
alert("it's broken");
}}
);
}
【问题讨论】:
标签: jquery xml ajax api opencalais