Web開発

a445c716 anonymous 2013-05-13 23:12
>>92f7631a
もうみてないだろうけど、コールバック関数を
受け取れるようにするのがいいと思う。

loadFile(url, function (text) {
  console.log(text);
});
function loadFile(fileURL, callback) {
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function () {
    if ( xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      callback(xmlhttp.responseText);
    }
  };
  xmlhttp.open("GET", fileURL, true);
  xmlhttp.send();
}

Top of this page. | <<last 0 1

limit: 15360KB

(Web開発/121/0.2MB)

Powered by shinGETsu.