<head>
<meta name="viewport" content="width=device-width" />
<title>Index1</title>
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script>
function suc(obj) {
alert(obj);
function err(xhr) {
alert(xhr.readystate);
}
}
</script>
</head>
<body>
<div>
<h1>异步</h1>
@using(Ajax.BeginForm("GetData", "Home", new AjaxOptions()
{
HttpMethod="Post",
OnSuccess="suc",
OnFailure="err",
LoadingElementId="imgLoad"
})){
<input type="text" name="txtname" value=" " />
<input type="submit" />
}
</div>
</body>
public ActionResult GetData()
{
string str = Request.Form["txtname"];
return Content(str+" "+DateTime.Now.ToString());
}
转载 请注明原文地址并标明转载:http://www.cnblogs.com/laopo
商业用途请与我联系:lcfhn168@163.com