このコードを使用して、クロスドメインの JSONP 呼び出しを行っています。
jQuery.ajax({
async: true,
url: 'http://mnews.hostoi.com/test.json',
dataType: 'jsonp',
method: "GET",
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus + ': ' + errorThrown);
},
success: function (data, textStatus, jqXHR) {
if (data.Error || data.Response) {
exists = 0;
}
}
});
Firebug でデバッグすると、次のエラーが発生します。
SyntaxError: missing ; before statement
ただし、jsonlint.com などのツールを使用して json オブジェクト (JQ コードのリンクから入手可能) を渡すと、有効な JSON であると表示されます。また異常も見当たりません。どのようにして構文エラーを返すのでしょうか? 私が取得していないJSONPの詳細ですか、それとも何ですか?
JSON サンプル
{"news":[ {
"sentences": [
"Neuroscientists have discovered abnormal neural activity...",
"The researchers found that these mice showed many symptoms...",
"\"Therefore,\" the study authors say, \"our findings provide a novel.."
],
"summaryId": "ZJEmY5",
"title": "Abnormal neural activity linked to schizophrenia"
}]}
前もって感謝します。