|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Calling an another page</title>
<script language="javascript" type="text/javascript">
//Creating the instanse of the XmlHttpRequest
// branch for native XMLHttpRequest object
var client=null;
if (window.XMLHttpRequest)
{
client = new XMLHttpRequest();
} // branch for IE/Windows ActiveX version
else if (window.ActiveXObject)
{
client = new ActiveXObject("Microsoft.XMLHTTP");
}
//sending information to server
function doCall()
{
try
{
client.onreadystatechange = callBack;
client.open("GET", document.getElementById("txtURL").value);
client.send();
}catch(ex)
{
alert(ex.message);
}
}
//waiting and processing server response
function callBack(response)
{
try
{
if(client.readyState == 4 && client.status == 200)
{
document.getElementById("panel").innerHTML=client.responseText;
}
}
catch(ex)
{
alert(ex.message);
}
}
</script>
</head>
<body>
<h4>Reading server responseUsing XMLHttpRequest</h4>
Server URL: <input id="txtURL" type="text" value="HtmlPage2.htm" />
<input type="button" value="Call" onclick="doCall()" />
<br />[Output]
<hr />
<div id="panel"></div>
<hr />
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
"Manikandan Balakrishnan" Working as an IT consultant with LogicaCMG’s Global Service Delivery part-India, he has a good experience on Web/Win development (C#, Asp.net) and enterprise application integration (BizTalk) technologies. Prior to this he worked on world’s biggest e-learning product with Excel Soft Technologies, Mysore.
City: Coimbatore, TN
CreativeManix@gmail.com