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