Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
620hun81886y@Stebner55 Vanilla ajax is so easy, no clue why anyone would use that monolithic piece of shit that jQuery is only for Ajax
-
@620hun
Easy? Sure...Concise and efficient? Nada...
And you don't need to grab the entire library just for ajax.
Vanilla:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'send-ajax-data.php');
xhr.send(null);
xhr.onreadystatechange = function () {
var DONE = 4; // readyState 4 means the request is done.
var OK = 200; // status 200 is a successful return.
if (xhr.readyState === DONE) {
if (xhr.status === OK)
console.log(xhr.responseText); // 'This is the returned text.'
} else {
console.log('Error: ' + xhr.status); // An error occurred during the request.
}
}
};
vs jquery:
$.get('send-ajax-data.php', function(response){ });
Related Rants
Finally it arrived!
random
vuejs