1
我懷疑這是因爲我沒有返回可以解析的JSON。下面是一個示例:
Response.ContentType = "application/json";
Response.Write(JsonConvert.SerializeObject(new {foo="bar"}));
鉻告訴我下面......「未捕獲的SyntaxError:意外的標記:」
這種方法產生同樣的反應:
return Json(new {foo="bar"}, JsonRequestBehavior.AllowGet);
我在做什麼錯誤?此外,這是一個跨域請求。
$.ajax({
url: myURL,
type: 'GET',
async: true,
dataType: 'jsonp',
cache: false,
success: function (data) {
alert(data);
}
});
編輯:這裏是JSON C#吐出:
{"foo":"bar"}