Home>

Use ajax technology to implement click button,Display the contents of txt text on the page through a pop-up box

The/* event will be triggered after the page is loaded.
* /
<script>
window.onload=function () {
/* Get the id of the button * /
Var obth=document.getelementbyid ("btn");
/* Function triggered by clicking button * //
Obth.onclick=function () {
/* Open browser * /
Var xhr=new xmlhttprequest ();
/* Enter the address in the address bar,1txt here represents the inner txt file that needs to be opened * /
Xhr.open ("get", "1.txt", true)
/*submit*/
Xhr.send ();
/* Etc. server returns content * /
Xhr.onreadystatechange=function () {
If (xhr.readystate == 4) {
Alert (xhr.responsetext);
}
}
}
}
</script>
<body>
<input type="button" value="button">
</body>
  • Previous C # using three usage methods
  • Next Threejs learning geometry