我想在ASP.NET MVC应用程序中进行ajax调用(使用JQuery)并返回一个布尔值,我该怎么做?
谢谢
解决方法:
好吧,可能最好的解决方案是使用JSON序列化.
public ActionResult DoSomething(string parameter)
{
//do something with parameter
bool result = true;
return Json(new ActionInfo()
{
Success =result,
});
}
ActionInfo只是一个带有一个属性的简单类,boolean Success.Then,jquery ajax调用:
$.ajax({
type: "POST",
url: "YourController/DoSomething?parameter=pValue",
data: {},
dataType: "json",
success: function(actionInfo) {
alert(actionInfo.Success);
}});
希望这可以帮助.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。