我正在嘗試新的jQuery 1.5,它在我的應用程序中破壞了一些東西。我打電話給一個產生JSON的動作,但是有些出錯並導致腳本停止。根據Fiddler和Firebug,該操作確實會返回JSON數據。我沒有提供JSON數據,但根據JSONLint,數據是有效的。
請注意,這符合jQuery 1.4.4的預期。
我注意到的第一件事情就是網址:http://localhost:3219/News/GetAllNewsArchives?callback=jQuery15033185029088076134_1296751219270&_=1296751219672
腳本:
// Dropdown box for past articles
$("#article-select").ready(function() {
$.ajaxSetup({ cache: false });
$.getJSON('/News/GetAllNewsArchives', null, function(json) {
var items = "<option value=''>(Select)</option>";
$.each(json, function(i, item) {
items += "<option value='" + item.Id + "'>" + subject + "</option>";
});
$("#article-select").html(items);
});
});
操作:
public ActionResult GetAllNewsArchives()
{
return Json(newsRepository.GetAllNewsArchives(), JsonRequestBehavior.AllowGet);
}
什麼我做錯了任何想法?
找到[jQuery.com論壇](https://forum.jquery.com/topic/getjson-and-jquery-1-5)中報告的已確認錯誤。 [見補丁](https://github.com/jzaefferer/jquery-validation/issues#issue/36)。 – 2011-02-07 16:03:09