标签:title text name pre for idt click txt highlight
前端:
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script>
$(function () {
$("#btn").click(function () {
$.ajax({
url: "/Home/Test",
data: {},
dataType: "json",
success: function (data) {
for (var s in data) {
$("#txt" + s).val(data[s]);
}
}
})
})
})
</script>
</head>
<body>
<div>
<input type="text" id="txtName" /><br />
<input type="text" id="txtPwd" /><br />
<button id="btn">提交</button>
</div>
</body>
</html>
后端:
public ActionResult Test()
{
Student stu = new Student()
{
Name="王大",
Pwd="123456"
};
return Json(stu, JsonRequestBehavior.AllowGet);
}
标签:title text name pre for idt click txt highlight
原文地址:http://www.cnblogs.com/sunice/p/6938754.html