たぼさんの部屋

いちょぼとのんびり

XLMHttpRequestをDOMとして受け取る

android標準ブラウザ、opera-miniは非対応の様子。

firefox , PCはok)

js

EFOLAB.XHR.prototype.open = function() {"use strict";
   /*
    * XMLHttpRequest で HTML を DOM として取得するのは、
    * XML を DOM として取得するのとそう変わりません。
    * ただ、非同期モードを利用しなければいけないことと、
    * XMLHttpRequest オブジェクトの open() をコールしたあと、
    * send() をコールする前に responseType プロパティに "document" を指定し、
    * 明示的に文書をリクエストしなければいけないという違いがあります。
    */
   console.log('open');
   this.xhr.open('GET', this.url);              //htmlモードには非同期しかないので第三引数不要
   this.xhr.responseType = "document";    //!!htmlとして取得するため。
   
   this.xhr.addEventListener('readystatechange', this, false);
   this.xhr.send();
};

で、responseXMLで受け取る
this.xhr.responseXML.getELementById('hoge');
とかで取得可能なんだが・・・