我有一个这样的搜索 ajax 请求:
$.ajax({
type: 'POST',
data: { FirstName: firstname, LastName: lastname},
contentType: "application/json; charset=utf-8",
url: 'GetPeople',
dataType: 'json',
}
});
在 GetPeole 操作中,我可以获得我的参数 (FirstName,LastName)
public virtual JsonResult GetPeople(string FirstName,string LastName)
{
....
}
如果我改变我的ajax请求
$.ajax({
type: 'POST',
data: { FirstName: firstname, LastName: lastname,Age=age},
contentType: "application/json; charset=utf-8",
url: 'GetPeople',
dataType: 'json',
}
});
我必须改变我的 GetPeople
public virtual JsonResult GetPeople(string FirstName,string LastName,int Age)
{
....
}
我想像这样在 Getpeople 中将我的搜索参数(名字,姓氏,年龄)作为对象
public virtual JsonResult GetPeople(searchParam)
{
.....
}