昨今、jQueryが下火になって久しい。 そこでjQueryのajax関数を使わずNativeなJavaScriptでどのようにAjaxを行うのかを調べたので備忘録として記述していく。 TL;DR; フロントエンドの規模が小さく、古いブラウザのサポートを気にする必要がないプロジェクトでは今後はFetchAPIを利用していったほうが良さそう。 従来のNativeなAjax XMLHttpRequest 過去のやり方であればXMLHttpRequestを使う方法も用意されていた。 しかし、これはjQueryのAjaxに慣れてしまった人には違和感も覚える人もいるだろう。 var request = new XMLHttpRequest(); request.open('post', '/foobar', true); request.setRequestHeader( 'Content-Type