posts - 4, comments - 3, trackbacks - 0, articles - 0

          導航

          <2007年2月>
          28293031123
          45678910
          11121314151617
          18192021222324
          25262728123
          45678910

          常用鏈接

          留言簿(1)

          隨筆分類(3)

          隨筆檔案(4)

          文章分類

          相冊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          另一種創建方式。似乎更加簡潔明了。用2個function完美的創建和調用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????}

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


          網站導航:
           
          主站蜘蛛池模板: 祁门县| 鹰潭市| 毕节市| 古田县| 漳平市| 车险| 沂源县| 武川县| 桃源县| 合作市| 临高县| 灵石县| 吕梁市| 恩施市| 濮阳县| 阿坝县| 盐山县| 疏勒县| 额尔古纳市| 衡南县| 通辽市| 三都| 攀枝花市| 永兴县| 抚顺市| 宾川县| 宾阳县| 南和县| 乳源| 新乡市| 育儿| 咸宁市| 永登县| 伊金霍洛旗| 阳原县| 通河县| 宿迁市| 福安市| 新密市| 微山县| 周宁县|