버튼을 클릭하면 Ajax을 사용하여 html 페이지를 표시합니다.Ajax http request close
내가 필요한 것은 ajax html 페이지를 닫는 또 다른 버튼을 만드는 것입니다. 나는 abort()를 시도했으나 그것이 필요한 것이 아니며 HTTP 요청을 중단하지 않기 위해 페이지를 닫아야한다.
<!DOCTYPE html>
<html>
<body>
<p id="demo">When you click the button it will load an HTML page</p>
<button type="button" onclick="loadDoc()">Open HTML Page</button>
<script>
function loadDoc() {
var xhttp;
if (window.XMLHttpRequest) {
// code for modern browsers
xhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "mypage.html", true);
xhttp.send();
}
</script>
</body>
</html>
'xhttp.close()' –