<!DOCTYPE html>
<html>
<head>
<script>
var xmlhttp;
function loadXMLDoc(url,cfunc)
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
alert("Ready state is: " + xmlhttp.readyState);
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
function myFunction()
{
loadXMLDoc("http://www.himansuit.com/shankarwcf/src1.svc/GetData",function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
});
}
</script>
</head>
<body>
<button type="button" onclick="myFunction()">Change Content</button>
<div id="myDiv"><h4>AJAX change this text.Changed text will come from server</h4></div>
</body>
</html>
No comments:
Post a Comment