How do I make an HTTP request in Javascript?
- Using the
XMLHttpRequest
object:
Copy codevar xhr = new XMLHttpRequest();
xhr.open("GET", "https://example.com", true);
xhr.onload = function () {
console.log(xhr.responseText);
};
xhr.send();
XMLHttpRequest
object:Copy codevar xhr = new XMLHttpRequest();
xhr.open("GET", "https://example.com", true);
xhr.onload = function () {
console.log(xhr.responseText);
};
xhr.send();