网页文本框获取URL返回值 - 前端代码实现
<label for='response-output'>返回值展示:</label>
<textarea id='response-output' rows='10'></textarea>
<button onclick='getUrlResponse()'>获取返回值</button>
<script>
function getUrlResponse() {
var url = document.getElementById('url-input').value;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('response-output').value = this.responseText;
}
};
xhttp.open('GET', url, true);
xhttp.send();
}
</script>
原文地址: https://www.cveoy.top/t/topic/nPAw 著作权归作者所有。请勿转载和采集!