Hatena::ブログ(Diary)

hogehoge @teramako RSSフィード

 | 

2011-11-22

Nightly の XMLHttpRequest で text/html がパース可能に!

Nightlyに入ったー

function getDocument (aURL, aCallback) {
  var xhr = new XMLHttpRequest;
  xhr.open("GET", aURL, true);
  xhr.responseType = "document";
  xhr.onreadystatechange = function() {
    if (xhr.readyState === xhr.DONE /* 4 */ &&
        xhr.status === 200) {
      aCallback(xhr.response);
    }
  };
  xhr.send(null);
}

getDocument("http://www.example.com", function (doc) {
  console.log(doc.querySelector("h1").innerHTML);
});

みたいな事が可能に!

来年3月が待ち遠しい!

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証

トラックバック - http://d.hatena.ne.jp/teramako/20111122/p1
 |