//发送请求的页面
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="logging.aspx.cs" Inherits="UI.admin.logging" %><!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 runat="server">
    <title>无标题页</title>
    <script type="text/javascript">
    var XmlHttp;
    function CreateXmlHttpRequest(){
    if(window.XMLHttpRequest){
    XmlHttp=new XMLHttpRequest();
    }
    else if(window.ActiveXObject){
    XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    }
    
    function OnReadyState(){
    CreateXmlHttpRequest();
     xmlHttp.onreadystatechange = StateChange;
    XmlHttp.open("Get","HandlerXmlHttp.ashx?id=1",true);
    XmlHttp.Send(null);
    }
    
    function StateChange(){
    if(XmlHttp.ReadyState==4){
    if(xmlHttp.status == 200){
    document.getElementById("dv1").innerHTML=XmlHttp.responseText;
    }
    }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="dv1">
        <input id="Button1" type="button" value="button" onclick="OnReadyState()" /></div>
    </form>
</body>
</html>//处理请求的页面
using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;namespace UI.admin
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class HandlerXmlHttp : IHttpHandler
    {        public void ProcessRequest(HttpContext context)
        {
            string myid = context.Request["id"];
            string retunStr = "";
            if (myid == "1")
            {
                retunStr = "不存在";
                context.Response.Write(retunStr);
            }
        }        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}