Use ajax technology to implement the txt pop-up method on the page, ajaxtxt

Source: Internet
Author: User

Use ajax technology to implement the txt pop-up method on the page, ajaxtxt

Click the button Using ajax to display the content in the TXT text to the page through the pop-up box.

/* The event is triggered after the page is loaded. */<Script> window. onload = function () {/* Get button id */var oBth = document. getElementById ('btn ');/* click the function triggered by the button * // oBth. onclick = function () {/* Open the browser */var xhr = new XMLHttpRequest ();/* enter the address in the address bar, here, 1txt indicates the internal txt file to be opened */xhr.open('get', '1.txt ', true)/* submit */xhr. send ();/* and other content returned by the server */xhr. onreadystatechange = function () {if (xhr. readystate = 4) {alert (xhr. responseText) ;}}}</script> <body> <input type = "button" value = "button" id = "btn"> </body>

The preceding Code uses ajax to open a text file through a pop-up window.

The method to use ajax technology to implement txt pop-up on the page is to share all the content with you through the small Editor. I hope you can give us a reference and support the house of helping customers.

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.