4 ms·
Hey wait. You consider AJAX plain javascript?
by 131012 8y ago
Hey wait. You consider AJAX plain javascript?
- throwawayloco 8y agoHere is how they are implementing AJAX - seems pretty vanilla to me: function ajaxRequest(method, url, payload) { return new Promise(function(resolve, reject) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (this.readyState == XMLHttpRequest.DONE) { if (this.status >= 200 && this.status < 500) { resolve(this); } reject(this); } } xhr.open(method, url, true); if (payload) { xhr.send(payload); } else { xhr.send(); } }); }