ajax基本實現

  var xmlHttpRequest;

              function createXML() {

                  if (window.ActiveXObject) {

                   xmlHttpRequest= new ActiveXObject( "Microsoft.XMLHTTP" );

                  }else{

                   xmlHttpRequest= new XMLHttpRequest();

                  }

              }

                

              function createlink() {

             

               createXML();

               var url= " <%= path %> /mgnt/newUserPP.shtml?method=add" ;

               xmlHttpRequest.onreadystatechange=handlestatechange;

               xmlHttpRequest.open( "GET" ,url, true );

               xmlHttpRequest.send( null );

              }

              function handlestatechange() {

               if (xmlHttpRequest.readyState==4) { //HTTP 就緒狀態,響應已完成,可以訪問服務器響應並使用它

                if (xmlHttpRequest.status==200) { // 服務器狀態碼

                 var response=xmlHttpRequest.responseText;

                 document.getElementById( "showurl" ).value=response;

                }

               }

              }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章