次の呼び出しを実行しようとすると、解析エラーが発生します。
$.ajax({
cache: true,
url: "http://localhost:3000/app/test/result1",
data: "{}",
type: "GET",
jsonpCallback: "testCall",
contentType: "application/jsonp; charset=utf-8",
dataType: "jsonp",
error: function (xhr, status, error) {
alert(error);
},
success: function (result) {
alert(result);
},
complete: function (request, textStatus) {
alert(request.responseText);
alert(textStatus);
}
});
リクエストのURLをブラウザのアドレスバーに直接貼り付けると、返される結果は有効なJSONのようです。
{
"name": "The Name",
"description": "The Description"
}
IISnode、NodeJs、ExpressJSを使用しています。私は両方のシナリオをテストしました:
// NODE JS CODE
var app = express();
app.get('/app/test/result1', function (req, res) {
res.send({ name: "The Name", description: "The Description" });
});
app.get('/app/test/result2', function (req, res) {
res.send(JSON.stringify({ name: "The Name", description: "the Description" }));
});
よろしくお願いします。