[英]ASP.Net AJAX $GetJson function won't get executed
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. 我真的不知道为什么,但是功能(响应)部分根本不会执行-尽管Controller中的Get方法由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". 我的span元素的Text不会更改为“ 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 然后,您需要使用带有JSON return的
JsonRequestBehavior.AllowGet
,并使用HttpGet
属性来修饰您的函数
[HttpGet]
public JsonResult GetMeasures(int buID) {
return Json(new { Success = true }, JsonRequestBehavior.AllowGet);
}
A good read Why is JsonRequestBehavior needed? 一本好书为什么需要JsonRequestBehavior?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.