以下是必需的任务:
注意:在此过程中页面不应刷新
答案 0 :(得分:0)
CodePen下方可以帮助您入门: 您的查询也应该通过此解决。
<html>
<input id='inp1' type='text'/>
</html>
<script>
var xhrObject = new XMLHttpRequest();
xhrObject.onreadystatechange = function() {
if (xhrObject.readyState === 4) {
if (xhrObject.status === 200 || xhrObject.status === 304) {
console.log(xhrObject.responseText);
var inp = document.getElementById('inp1');
inp.value = xhrObject.responseText;
}
}
};
xhrObject.open(
"GET",
"http://codepen.io/chriscoyier/pen/difoC.html",
true
);
xhrObject.send();
</script>