<button id="button">点击按钮返回一张随机图片地址</button> <p id="result"> </p>
var button = document.getElementById('button'); var result = document.getElementById('result'); button.addEventListener('click', function () { var xhr = new XMLHttpRequest(); xhr.open('post', 'http://www.zhangxinxu.com/study/201802/cros-ajax.php'); xhr.onload = function () { result.innerHTML = xhr.responseText; }; xhr.send(null); });