3 javascript ajax asp.net-mvc jquery
我想在ASP.NET MVC应用程序中进行ajax调用(使用JQuery)并返回一个布尔值,我该怎么做?
谢谢
Mis*_* N. 13
好吧,可能最好的解决方案是使用JSON序列化.
public ActionResult DoSomething(string parameter)
{
//do something with parameter
bool result = true;
return Json(new ActionInfo()
{
Success =result,
});
}
Run Code Online (Sandbox Code Playgroud)
ActionInfo只是一个带有一个属性的简单类,boolean Success.Then,jquery ajax调用:
$.ajax({
type: "POST",
url: "YourController/DoSomething?parameter=pValue",
data: {},
dataType: "json",
success: function(actionInfo) {
alert(actionInfo.Success);
}});
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
5948 次 |
| 最近记录: |