posts - 4, comments - 3, trackbacks - 0, articles - 0
          另一種創(chuàng)建方式。似乎更加簡潔明了。用2個function完美的創(chuàng)建和調(diào)用xmlhttp Object。

          ?1????//xmlhttp.js
          ?2????
          ?3????//Function?to?create?an?XMLHttp?Object.
          ?4????function?getxmlhttp?(){
          ?5????????//Create?a?boolean?variable?to?check?for?a?valid?microsoft?active?X?instance.
          ?6????????var?xmlhttp?=?false;
          ?7????????
          ?8????????//Check?if?we?are?using?internet?explorer.
          ?9????????try?{
          10????????????//If?the?javascript?version?is?greater?than?5.
          11????????????xmlhttp?=?new?ActiveXObject("Msxml2.XMLHTTP");
          12????????}
          ?catch?(e)?{
          13????????????//If?not,?then?use?the?older?active?x?object.
          14????????????try?{
          15????????????????//If?we?are?using?internet?explorer.
          16????????????????xmlhttp?=?new?ActiveXObject("Microsoft.XMLHTTP");
          17????????????}
          ?catch?(E)?{
          18????????????????//Else?we?must?be?using?a?non-internet?explorer?browser.
          19????????????????xmlhttp?=?false;
          20????????????}

          21????????}

          22????????
          23????????//If?we?are?using?a?non-internet?explorer?browser,?create?a?javascript?instance?of?the?object.
          24????????if?(!xmlhttp?&&?typeof?XMLHttpRequest?!=?'undefined')?{
          25????????????xmlhttp?=?new?XMLHttpRequest();
          26????????}

          27????????
          28????????return?xmlhttp;
          29????}

          30????
          31????//Function?to?process?an?XMLHttpRequest.
          32????function?processajax?(obj,?serverPage){
          33????????//Get?an?XMLHttpRequest?object?for?use.
          34????????var?theimg;
          35????????xmlhttp?=?getxmlhttp?();
          36????????xmlhttp.open("GET",?serverPage);
          37????????xmlhttp.onreadystatechange?=?function()?{
          38????????????if?(xmlhttp.readyState?==?4?&&?xmlhttp.status?==?200)?{
          39????????????????document.getElementById(obj).innerHTML?=?xmlhttp.responseText;
          40????????????}

          41????????}

          42????????xmlhttp.send(null);
          43????}

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 富平县| 南溪县| 吉水县| 辽阳市| 吴川市| 杭锦后旗| 称多县| 吉林省| 东乡族自治县| 博野县| 永新县| 时尚| 富裕县| 随州市| 齐河县| 寿宁县| 新昌县| 象山县| 喀喇沁旗| 方山县| 岚皋县| 龙州县| 永新县| 谢通门县| 美姑县| 建湖县| 塔城市| 新丰县| 瓦房店市| 新化县| 红桥区| 安远县| 神木县| 白城市| 茌平县| 仁化县| 安乡县| 洛扎县| 博白县| 灵川县| 成都市|