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????}

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


          網站導航:
           
          主站蜘蛛池模板: 祁门县| 威信县| 封开县| 剑河县| 西城区| 和静县| 邛崃市| 洞头县| 隆林| 凤阳县| 巴南区| 类乌齐县| 林甸县| 巨野县| 东方市| 巴楚县| 申扎县| 海口市| 阆中市| 岱山县| 余干县| 呼伦贝尔市| 巢湖市| 秦皇岛市| 巨鹿县| 同仁县| 工布江达县| 清原| 黄平县| 太仓市| 望谟县| 宁城县| 洪雅县| 包头市| 南昌市| 河源市| 福泉市| 五家渠市| 舟山市| 龙泉市| 昌邑市|