我正在研究一个asp.net mv3应用程序。Jquery/ajax从一个类中获取对象,并在我的视图中的文本框中使用它
在一个辅助类,我有一个返回的人的对象基于他的ID
public Person GetPersonByID(string id)
{
// I get the person from a list with the given ID and return it
}
在视图中我需要创建一个jQuery或JavaScript函数可以调用GetPersonByID
function getPerson(id) {
//I need to get the person object by calling the GetPersonByID from the C#
//helper class and put the values Person.FirstName and Person.LastName in
//Textboxes on my page
}
我该怎么做?
这可以通过使用和ajax调用?
$.ajax({
type:
url:
success:
}
});
任何帮助是极大的赞赏
感谢
我想学这个,因为我在做一些非常相似。在你的'.ajax'中,'id'字符串的值是在哪里设置的?那将会传递给'ActionResult'方法的东西是否正确?另外,如果我的ActionResult方法没有或不需要输入参数呢? – 2015-09-17 17:42:15