AJAX. Simple AJAX code to read HTML file and display in div
.
<script>
var obj;
function readHTML(url) {
if( window.XMLHttpRequest ) {
obj = new XMLHttpRequest();
obj.onreadystatechange = processChange;
obj.open("GET", url, true);
obj.send(null);
} else if( window.ActiveXObject ) {
obj = new ActiveXObject("Microsoft.XMLHTTP");
obj.open("GET", url, true);
obj.send();
} else {
alert("Your browser does not support AJAX");
}
}
function processChange() {
if( (obj.readyState==4) && (obj.status==200) ) {
var myDiv = document.getElementById("readhtmlid");
myDiv.innerHTML = obj.responseText;
} else {
alert("something went wrong.");
}
}
readHTML("http://url/css.html");
</script>
<div id="readhtmlid"></div>
No comments:
Post a Comment