Html程序  |  33行  |  739 B

<html>
<head>
<script>
var request_success = false;

function OnLoad() {
  var request = new XMLHttpRequest();
  request.open("GET", "title1.html", false);
  request.send("");

  var my_div = document.getElementById("my_div");
  if (request.readyState == 4 && request.status == 200) {
    request_success = true;
    my_div.innerHTML = "Got a successful response: " + request.responseText;
  } else {
    my_div.innerHTML = "Request failed: ready state=" + request.readyState +
                       " status=" + request.status;
 }
}

function DidSyncRequestSucceed() {
  return request_success;
}

</script>
</head>
<body onload="OnLoad();">
This page sends a synchronous XMLHttpRequest.
<br><br>
<div id="my_div"></div>
</body>
</html>