码迷,mamicode.com
首页 > Web开发 > 详细

asp.net mvc 微软异步请求

时间:2017-02-17 23:43:19      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:microsoft   val   play   return   data   user   ng2   option   pos   

        public ActionResult GetDateTime(string userName,int age)
        {
            System.Threading.Thread.Sleep(2000);
            return Content(DateTime.Now.ToString() + userName + age);
        }

        public ActionResult MicroSoftAjax()
        {
            return View();
        }
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>MicroSoftAjax</title>
    <script src="~/Scripts/jquery-1.8.2.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <script type="text/javascript">
        function afterSuccess(data)
        {
            alert("成功回调"+data);
        }
    </script>
</head>
<body>
    <div id="divLoading" style="display:none">
        <img src="~/Content/Images/ico_loading2.gif" />
    </div>
    <div>
        @using (Ajax.BeginForm("GetDateTime", "User", new AjaxOptions() {
            Confirm="您真的要提交吗?",
            HttpMethod="Post",
            InsertionMode=InsertionMode.Replace,
            UpdateTargetId = "divResult",
            OnSuccess="afterSuccess",
            LoadingElementId="divLoading"
        }))
        {
            <div>
                用户名:<input type="text" name="userName"/><br/>
                年龄:<input type="text" name="age"/><br/>
                <input type="submit" value="提交"/>
            </div>
        }
        <div id="divResult"></div>
    </div>
</body>
</html>

 

asp.net mvc 微软异步请求

标签:microsoft   val   play   return   data   user   ng2   option   pos   

原文地址:http://www.cnblogs.com/caohuimingfa/p/6411542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!