标签:tle proc 获取 title www oid pos 1.7 jquer
使用jquery完成异步操作
-》开发文档提供的异步API
url:请求地址
type:请求方式,主要是get、post
data:{}:请求的数据
dataType:返回值的类型,主要有xml、text、json、script、html
success:function(data){...}成功的回调函数(4,200)
GetTime.html
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title></title> 6 <script src="js/jquery-1.7.1.min.js"></script> 7 <script> 8 $(function () { 9 $(‘#btnGetTime‘).click(function () { 10 $.ajax({ 11 url: ‘GetTime.ashx‘, 12 type: ‘post‘,//‘get‘, 13 data: { 14 ‘title‘: ‘xlb‘ 15 }, 16 dataType: ‘html‘, 17 success: function (msg) { 18 $(‘#showTime‘).html(msg); 19 } 20 }); 21 22 //$.get(‘GetTime.ashx‘, 23 // ‘title=yg‘, 24 // function(msg) { 25 // $(‘#showTime‘).html(msg); 26 // } 27 // ); 28 29 }); 30 }); 31 </script> 32 </head> 33 <body> 34 <input type="button" id="btnGetTime" value="获取时间" /> 35 <div id="showTime"></div> 36 </body> 37 </html>
GetTime.ashx
1 public class GetTime : IHttpHandler 2 { 3 4 public void ProcessRequest(HttpContext context) 5 { 6 context.Response.ContentType = "text/html"; 7 8 string title = context.Request["title"]; 9 10 context.Response.Write("<h1>" + DateTime.Now.ToString() + "_" + title + "</h1>"); 11 } 12 13 public bool IsReusable 14 { 15 get 16 { 17 return false; 18 } 19 } 20 }
标签:tle proc 获取 title www oid pos 1.7 jquer
原文地址:http://www.cnblogs.com/ninghongkun/p/6345121.html