标签:
1.基与jquery的异步请求
<script src="~/Scripts/jquery-1.8.2.min.js"></script> <script type="text/javascript"> $(function() { $("#btn_jquery").click(function() { $.ajax({ url: "/Users/Getdata", type: "POST",
data:"", success: function(data) { alert(data); } }); }); }); </script> </head> <body> <div> <input type="button" value="获取" id="btn_jquery"/> </div> </body>
2.基与微软自带的mvc异步请求
<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> @using (Ajax.BeginForm("GetDate", "Ajax", new AjaxOptions(){Confirm ="您是否要提交吗?",HttpMethod = "Post", InsertionMode = InsertionMode.InsertAfter@*有3种选择,直接替换,加载在后面*@,UpdateTargetId = "result"/*请求的数据在这个id里*/,OnSuccess="afterSuccess"/*请求成功后调用javascript*/,LoadingElementId = "loading"/*加载图片*/})) { <div> 用户名:<input type="text" name="UserName" /><br /> 密码:<input type="text" name="Pwd"/><br /> <input type="submit" value="提交"/> </div> } <div id="result"> </div> <div id="loading" style="display:none"> <img src="~/Content/ico_loading2.gif" /> </div> </div> </body>
继续下一章.....
标签:
原文地址:http://www.cnblogs.com/jsdvkm/p/4581929.html