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');
    }
  }
};
JavaScript XMLHttpRequest GET Request Example: Loading 'smsc.js'

原文地址: http://www.cveoy.top/t/topic/mOJY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录