
AJAX Example
1. AJAX example with JavaScript to get content of another file.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function fun1()
{
var obj = new XMLHttpRequest();
obj.onreadystatechange = function(){
if(obj.readyState==4 && obj.status==200)
{
document.getElementById("msg").innerHTML = obj.responseText;
}
}
obj.open("GET","audio.html",true);
obj.send();
}
</script>
</head>
<body>
<input type="button" value="load" onclick="fun1()" />
<div id="msg">
</div>
</body>
</html>
Output :