参考答案:
1const getJSON = function(url) { 2 return new Promise((resolve, reject) => { 3 const xhr = XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Mscrosoft.XMLHttp'); 4 xhr.open('GET', url, false); 5 xhr.setRequestHeader('Accept', 'application/json'); 6 xhr.onreadystatechange = function() { 7 if (xhr.readyState !== 4) return; 8 if (xhr.status === 200 || xhr.status === 304) { 9 resolve(xhr.responseText); 10 } else { 11 reject(new Error(xhr.responseText)); 12 } 13 } 14 xhr.send(); 15 }) 16} 17
最近更新时间:2021-07-07
题库维护不易,您的支持就是我们最大的动力!