JavaScript XMLHttpRequest GET Request Example: Loading 'smsc.js'
let xhr = new XMLHttpRequest();
xhr.open('GET', 'js/smsc.js');
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
alert(xhr.responseText);
} else {
console.error('Error loading file');
}
}
};
原文地址: http://www.cveoy.top/t/topic/mOJY 著作权归作者所有。请勿转载和采集!