------------------------------ WebService1.asmx----------------------------------
// 若要允許使用 ASP.NET AJAX 從指令碼中調用此 Web 服務,請取消對下行的注釋。
    [System.Web.Script.Services.ScriptService]
     public class WebService1 : System.Web.Services.WebService
     {
         [WebMethod]
         public string HelloWorld()
         {
             return "Hello World";
         }
     
         [WebMethod]
         public string GetDate()
         {
             return DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
         }
    }
------------------------------------HTMLPage1.htm---------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <title></title>
      <script src="js/Jquery1.7.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(function () {
            function GetDate() {
                $.ajax({
                    type: "post", //用戶端向伺服器發送請求時採取的方式
                    contentType: "application/json", //指定用戶端發送給伺服器的內容的類型以及伺服器返回給用戶端內容的類型為json格式
                   url: "WebService1.asmx/GetDate", //指明用戶端要向哪個頁面裡面的哪個方法發送請求
                    data: "{}", //指定伴隨發送的請求傳遞到伺服器的參數
                    success: function (result) {//用戶端調用伺服器端方法成功後執行的回呼函數。
                       $('#mydiv').text(result.d);
                    }
               })
           }
             setInterval(GetDate, 1000);
         })
     </script>
 </head>
 <body>
 <div id="mydiv"></div>
     <input id="Button1" type="button" value="擷取伺服器時間" />
 </body>
 </html>