AJAX with ‘fetch’

‘fetch’ is a feature added since ES6 GET fetch('http://example.com/movies.json') .then(response => response.json()) .then(data => console.log(data)); POST Old Version var url = 'YOUR URL HERE' var xhr = new XMLHttpRequest() const form = document.getElementById("form-id"); var formData = new FormData(form);// it could be new FormData() also xhr.open('POST', url, true); xhr.addEventListener('readystatechange', function(e) { if (xhr.readyState == 4 &&…