Web開発

92f7631a anonymous 2013-05-05 18:42
で、早速なんだけど質問です。そうです。質問したかったので立てたんです。
console.log( loadFile( url));
function loadFile ( fileURL) {
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function () {
    if ( xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      return xmlhttp.responseText;
    }
  };
  xmlhttp.open( "GET", fileURL, true);
  xmlhttp.send();
}
これは非同期だからコンソール出力はUndefinedになるんだけど、返って来たら受け取りたいときは普通どうすんの?setTimeoutで再帰ループ組んで確認ですか?

Top of this page. | <<last 0 1

limit: 15360KB

(Web開発/121/0.2MB)

Powered by shinGETsu.