<from id='form1'>
<input type='text' name='user' id='user' /><br/>
<input type='password' name='pwd' id='pwd' /><br/>
<input type='button' id='btn' name='btn'/>
<table>
<tr>
<td>用户名</td>
<td>密码</td>
</tr>
</table>
</form>
<script>
$.ajax({
type:'get',
url:'home/Red',
async:'false',
date:$('#form1').serialize(),
dataType:'json',
success:function(obj){
$.each(obj,function(name,values){
$('table').appen("<tr><td>"+name+"</td><td>"+values+"</td></tr>");
})
}
});
</script>
public class HomeController:Controller
{
public JsonResult Red(string user, string pwd)
{
Person p = new Person() { Name=user,Pwd=pwd};
return Json(p, JsonRequestBehavior.AllowGet);
}
}