which one should i use and why?
and what is the differents (im a beginner)
and what is the differents (im a beginner)
Code:
var xhr = new XMLHttpRequest();
xhr.onload = function() {alert(1)};
xhr.open("get", "http://--------.com", true);
xhr.send();
Code:
var xhr = new XMLHttpRequest();
xhr.addEventListener( "loadend", function() {alert(1)} );
xhr.open("GET", "http://--------.com", true);
xhr.send();
Code:
var request = $.ajax({
type: 'GET',
url: "http://--------.com",
async: true,
success: function() {alert(1);}
});
Code:
var request = $.get("http://--------.com").done(function() {
alert(1);
});
Code:
fetch("http://--------.com").then(function(response) {
alert(1);
});
Code:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {"done"}
}
xhr.open("GET", "http://--------.com", true);
xhr.send();