この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:2
ページ更新者:guest
更新日時:2017-11-03 14:45:57

タイトル: 同期処理

これはJavascriptの同期処理に関する記事です。

例文

var request = new XMLHttpRequest();
request.open('GET', url1, false);
request.send(null);

//リクエストが成功した場合
if (request.status === 200) {
  console.log(request);
}

 

同期処理を行うとChromeブラウザで以下の警告が出る。

警告
[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

要約するとメインスレッドでの同期処理は廃棄予定とのこと。