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

MVC 异步请求

时间:2015-09-20 14:34:17      阅读:123      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!