[英]ASP.Net AJAX $GetJson function won't get executed
我真的不知道為什么,但是功能(響應)部分根本不會執行-盡管Controller中的Get方法由getJSON調用。
腳本:
$.getJSON(getUrl, {
BUID: buID,
AID: aID,
LID: lID
}, function (response) {
$('#Test').text("TEST");
})
};
控制器:
public JsonResult GetMeasures(int buID) {
return Json(new { Success = true });
}
我的span元素的Text不會更改為“ TEST”。
發送正確的參數:
$.getJSON(getUrl, {
buID: buID
}, function (response) {
$('#Test').text("TEST");
})
};
然后,您需要使用帶有JSON return的JsonRequestBehavior.AllowGet
,並使用HttpGet
屬性來修飾您的函數
[HttpGet]
public JsonResult GetMeasures(int buID) {
return Json(new { Success = true }, JsonRequestBehavior.AllowGet);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.