Sorry if I've worded this badly, but I have some lines of js:
var client = new XMLHttpRequest(); client.open('GET', '/test.txt'); client.onloadend = function() { alert(client.responseText); } client.send(); var x = document.getElementById("demo").innerHTML = x;
<div id="demo"></div>
How can I make var x = the value of the alert box?
var client = new XMLHttpRequest(); client.open('GET', '/test.txt'); client.onload = e => { document.getElementById("demo").innerHTML = e.target.responseText); }; client.send(); var x = document.getElementById("demo").innerHTML = x;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.