Using AJAX technology to implement TXT popup on the page _ajax related

Source: Internet
Author: User

Use AJAX technology to implement the Click button, the contents of the TXT text through the pop-up box displayed on the page

/* Events are triggered after the page load completes. * *

<script>

window.onload = function () {

/* get button id*/

var obth=document.getelementbyid (' btn ') ;

/* Click on the button trigger function *//

Obth.onclick = functions () {/

* Open Browser

/var xhr = new XMLHttpRequest ();

/* Enter the address in the Address bar, where the 1txt on behalf of the need to open a TXT file

/xhr.open (' Get ', ' 1.txt ', true)/

* Submit * *

xhr.send ();

/* Server return content

/* Xhr.onreadystatechange = function () {

if (xhr.readystate==4) {

alert (xhr.response Text)

;

}}} </script>

<body>
<input type= "button" value= "buttons" id= "btn" >
</body>

The above is the use of AJAX implementation through the pop-up window to open a text file.

Using AJAX technology to achieve TXT pop-up on the page is a small series to share all the content, I hope to give you a reference, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.