I really don't know why but the function(response)-part won't be executed at all - although the Get Method in my Controller gets called by getJSON.
Script:
$.getJSON(getUrl, {
BUID: buID,
AID: aID,
LID: lID
}, function (response) {
$('#Test').text("TEST");
})
};
Controller:
public JsonResult GetMeasures(int buID) {
return Json(new { Success = true });
}
The Text of my span element doesn't get changed into "TEST".
Send correct parameters:
$.getJSON(getUrl, {
buID: buID
}, function (response) {
$('#Test').text("TEST");
})
};
And then you need to use JsonRequestBehavior.AllowGet
with JSON return, Also decorate your function with HttpGet
attribute
[HttpGet]
public JsonResult GetMeasures(int buID) {
return Json(new { Success = true }, JsonRequestBehavior.AllowGet);
}
A good read Why is JsonRequestBehavior needed?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.