📜  js 然后 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:10.648000             🧑  作者: Mango

代码示例5
function myAsyncFunction(url) {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", url);
    xhr.onload = () => resolve(xhr.responseText);
    xhr.onerror = () => reject(xhr.statusText);
    xhr.send();
  });
}