首页 > Web开发 > 详细

MVC 异步请求

时间:2015-09-20 14:33:31      阅读:252      评论:0      收藏:0      [点我收藏+]
<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());
        }

 

MVC 异步请求

原文:http://www.cnblogs.com/laopo/p/4823318.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!