The idea of getting HTML file from JS and the example _javascript skill

Source: Internet
Author: User
Copy Code code as follows:

function readhtml () {
$.ajax ({
Async:false,
URL: "Aa.html",
Success:function (Result) {
alert (result);
}
});
}

Async:false, this is to do with other JS sync, if True or not fill will run the same level of other code, that is, the result is empty here, only after the execution of other code to run the inside of things, result will have a value, which is usually not required

The expression may not be very clear, you do a test on the clear, this is a detailed example of this attribute: http://www.cnblogs.com/wlmemail/archive/2010/06/22/1762765.html

Note: This is the use of jquery

Using JS words is the following code
Copy Code code as follows:

var xmlhttp;
if (window. XMLHttpRequest) {//compatible ie7+, Firefox, Chrome, Opera, Safari
XMLHTTP = new XMLHttpRequest ();
}
else {//compatible IE6, IE5
XMLHTTP = new ActiveXObject ("Microsoft.XMLHTTP");
}
Xmlhttp.onreadystatechange = function () {
if (xmlhttp.readystate = = 4 && xmlhttp.status = 200) {
document.getElementById ("Mydiv"). InnerHTML = Xmlhttp.responsetext;
}
}
Xmlhttp.open ("Get", "aa.html", true);
Xmlhttp.send ();

Mydiv is the position you output, this is a div defined on the page

This is the source of my problem solving: http://stackoverflow.com/questions/8197709/javascript-read-html-from-url-into-string
Reference: Http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first

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.