没有建立AJAX框架怎么实现选择了CheckBox提交后页面不刷新

解决方案 »

  1.   

    <script type="text/javascript">
    var xmlHttp;
    //创建一个XmlHttpRequeset对象
    function createXMLHttpRequest(){
        
        if(window.ActiveXObject){
             xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
         }
        else if(window.XMLHttpRequest){
             xmlHttp = new XMLHttpRequest();
         }
    }
    //开始一个请求
    function startRequest(){
        
         createXMLHttpRequest();
         xmlHttp.onreadystatechange = handlestatechange;
         xmlHttp.open("GET", "test.txt", true);
         xmlHttp.Send(null);
    } function handlestatechange(){
        if(xmlHttp.readyState == 4){//描述一种"已加载"状态;此时,响应已经被完全接收。
            if(xmlHttp.status == 200){//200表示成功收到        
                 returen xmlHttp.responseText; //返回值
               
             }
             else{
                 alert("失败");
             }
         }
    }
      

  2.   

    请问test.txt是控件名字还是什么?
    在CS文件里面怎么写?
      

  3.   

    CheckBox.Attibutes.Add("onchange","A()“)
    var xmlHttp; 
    function createXMLHttpRequest(){ 
        
        if(window.ActiveXObject){ 
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        else if(window.XMLHttpRequest){ 
            xmlHttp = new XMLHttpRequest(); 
        } 
    }  function A(id)
    {
                if (id == "")
                    return;
                var url = "../RegistValidate.ashx?username=" + escape(id);
                xmlHttp.open("GET", url, true);
                xmlHttp.onreadystatechange = ShowResult;
                xmlHttp.send(null);
            }
            function ShowResult() {
                
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        var s;
                      
                        s = xmlHttp.responseText;
                    
                        
                    }
                    else {
                        
                    }
                }
               
            }
      

  4.   

    回调函数,实现ICallBackEventHandle