JqueryAjax异步加载在ASP.NET
生活随笔
收集整理的這篇文章主要介紹了
JqueryAjax异步加载在ASP.NET
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前臺代碼
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript">function ShowCurrentTime() {$.ajax({url: "webService.aspx/GetCurrentTime",//請求的頁面/頁面處理數據的方法type: "POST", //傳輸方式contentType: "application/json;charset=utf-8", //編碼dataType: "json", //格式data: '{name: "' + $("input[name='name']").val() + '" ,age:"' + $("input[name='age']").val() + '"}',//json字符串success: function (data) { //成功以后的回調函數alert(data.d);},failure: function (data) {alert(data.d);}})} </script> <body><form id="form1" runat="server"><div><input type="text" name="name" /><input type="text" name="age" /><input type="button" value="獲取當前時間" onclick="ShowCurrentTime()" /></div></form>webService.aspx后臺代碼:
[System.Web.Services.WebMethod] //將 WebMethod 屬性附加到 Public 方法表示希望將該方法公開為 XML Web services 的一部分public static string GetCurrentTime(string name,string age){return "Hello"+name+age+DateTime.Now.ToString();}?
轉載于:https://www.cnblogs.com/tangt/p/4371706.html
總結
以上是生活随笔為你收集整理的JqueryAjax异步加载在ASP.NET的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在asp.net mvc中使用Parti
- 下一篇: Think Python - Chapt