//获取元素对象 const btns = document.querySelectorAll('button'); let x = null; btns[0].onclick = function(){ x = new XMLHttpRequest(); x.open("GET",'http://127.0.0.1:8000/delay'); x.send(); } // abort 取消AJAX请求 btns[1].onclick = function(){ x.abort(); }
2024-02-02 16:43:52
//获取元素对象 const btns = document.querySelectorAll('button'); let x = null; btns[0].onclick = function(){ x = new XMLHttpRequest(); x.open("GET",'http://127.0.0.1:8000/delay'); x.send(); } // abort 取消AJAX请求 btns[1].onclick = function(){ x.abort(); }