用Ajax调用操作方法

I tried the solution below without success. In the controller method MvcAction, the prs parameter is always null. Below is the code I'm using to call the controller method.

function getPerson() {
    var jFirstName = '@Model.Person.FirstName';
    var jLastName = '@Model.Person.LastName';
    return { FirstName: jFirstName, LastName: jLastName };
}

var person = getPerson();
var jsonPerson = JSON.stringify(person);

$.post( '@Url.Action("MvcAction", "MvcXontroller")', { prs : jsonPerson },
function( data ) {
    ....
});

The action method look like this:

public void MvcAction(Person prs)
{

}
查看全部
weixin_33739523
weixin_33739523
2011/11/02 18:51
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

1个回复