PHPプログラミング実戦15-5
1091 ワード
Original content
var xhr = new XMLHttpRequest();
// URL
xhr.open("GET", window.location.pathname, true);
// window.location.pathname==untitled/a.php
//
xhr.onreadystatechange = function () {
//console.log(xhr.readyState);
if (xhr.readyState == 4) {
var message = "";
//console.log(xhr.status);
if (xhr.status = 200) {
message = "Ajax loaded content";
}
else {
message = "An error has occured making the request";
}
document.getElementsByTagName("p")[0].innerHTML = message;
}
}
//
xhr.send(null);