0

Jquery を使用してOpen Calais API からデータを取得しようとしていますが、有効な応答が得られない場合。データ型 "script" を使用すると、"missing ; before statement." というエラーが発生します。データ型 "xml" などを使用すると、Open Calais サーバーから 403 エラーが発生します。

このカレーフォーラム投稿の最後のエントリに基づいて、「スクリプト」データ型を試すことにしました

私のコードに関する批評やコメントを差し控えないでください。行く度に傾いています。

私のコード:

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");
    }}
);

}

4

2 に答える 2

1

これは、同一オリジン ポリシーによるものです。クロスドメイン リクエストに単純な ajax リクエストを使用することはできません。詳細については、この質問に対する私の回答を参照してください。このチュートリアルに従って、この問題を解決する方法について詳しく知ることができます。

于 2012-03-10T06:10:38.820 に答える
0


上記のスクリプトで記述された関数に構文エラーがあったため、次の関数を使用してください。

function sendIt(sendData){
$.ajax({
    url:componentURL,
    type: "POST",
    dataType:"script",
    success:function(data){
            alert(data); 
            console.log(data);
    },
    error:function(){
    alert("it's broken");
    }}
);
}
于 2012-03-10T05:50:12.667 に答える