代码示例:(标识:eg_js_ajax_get_unique)
<!DOCTYPE html>
<html>
<body>

<h1>XMLHttpRequest 对象</h1>

<button type="button" onclick="loadDoc()">请求数据</button>

<p>单击该按钮几次以查看时间是否已更改,或文件是否已缓存。</p>

<p id="demo"></p>

<script>
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange=function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "/index/demo/form_current.html?t=" + Math.random(), true);
  xhttp.send();
}
</script>

</body>
</html>
运行结果: