使用 iframe 来实现不刷新页面改变局部内容 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"><!-- var isInit = false; $ = function $(id) { return document.getElementById(id); } function ajax() { $('img').style.display = ''; $('div').innerHTML = 'please wait ...'; $('ifr').src = 'Handler.ashx?d=' + new Date(); } function callback() { if (isInit) { $('div').innerHTML = $('ifr').contentWindow.document.body.innerHTML; $('img').style.display = 'none'; } else { isInit = true; } } // --></script> </head> <body> <img id='img' alt='please wait.gif' src="http://preloaders.net/generator.php?image=82&speed=5&fore_color=77D1E3&back_color=FFF9F9&size=110x64&transparency=0&reverse=0&uncacher=56.31536443080266" style="display: none;" mce_style="display: none;" /> <br /> <br /> <div id='div'> </div> <br /> <input type="button" οnclick="ajax();" value="click me" /> <iframe id="ifr" οnlοad="callback();" style="display:none;" mce_style="display:none;" ></iframe> </body> </html> Handler.ashx.cs <%@ WebHandler Language="C#" Class="Handler" %> using System; using System.Web; public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; System.Threading.Thread.Sleep(3000); context.Response.Write(string.Format("当前时间是{0}", DateTime.Now)); context.Response.End(); } public bool IsReusable { get { return false; } } }