📜  xmlhttprequest 错误处理 - Javascript 代码示例

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

代码示例1
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       console.log( xhttp.responseText );
    }
};
// Error Handling:
xhttp.onerror = function(error){
    console.error( error );
}
xhttp.open("GET", "filename", true);
xhttp.send();