首页 > 代码库 > Js之AJAX

Js之AJAX

var xmlHttp;

         function createHttp() {

             try {

                 xmlHttp = new XMLHttpRequest();

             } catch (e) {

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

             }

         }

 createHttp();

             xmlHttp.onreadystatechange = function () {

                 if (xmlHttp.status == 200 && xmlHttp.readyState == 4) {

 

                     var data = http://www.mamicode.com/xmlHttp.responseText;

                     document.getElementById("div1").innerHTML = data;

                 }

             }

             xmlHttp.open("get", "HandlerData.ashx");

             xmlHttp.send();

Js之AJAX