Language & Framework/Javascript
[Javascript] XMLHttpRequest 사용법
수미수
2023. 9. 28. 22:58
반응형
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://jsonplaceholder.typicode.com/posts/1');
xhr.responseType = 'json';
xhr.onload = function(e) {
if (this.status == 200) {
console.log('response', this.response); // JSON response
}
};
xhr.send();
반응형