You can copy and paste the following into a .aspx page (change names
for your purpose) and it will call a webservice on every 1 minute. I
used this piece of code for the purpose of refreshing a datagrid
without having to make a postback to the server.
<script language="javascript">
function startRefreshDelay() {
UpdateGrid();
timer = setTimeout("startRefreshDelay()",60000);
}
function UpdateGrid()
{
var xmlObj = new ActiveXObject("Msxml2.DOMDocument");
var sXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
sXml += "<soap:Envelope "
sXml += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
";
sXml += "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ";
sXml += "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
sXml += "<soap:Body>";
sXml += "<GetDailyRetailKPI xmlns=\"http://www.tempuri.org/\">";
sXml += "<strXML><testnode>test</testnode></strXML>";
sXml += "</GetDailyRetailKPI></soap:Body></soap:Envelope>";
// Try to parse the XML string into DOM object
xmlObj.loadXML(sXml);
var xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
xmlHTTP.Open ("Post", "http://eis/GridXML/GridXML.asmx", false);
xmlHTTP.setRequestHeader("SOAPAction",
"http://tempuri.org/GetDailyRetailKPI");
xmlHTTP.setRequestHeader("Content-Type", "text/xml; charset=utf-8"
);
xmlHTTP.Send(sXml);
var xmlResponse = xmlHTTP.responseXML ;
DailyRetailKPI.innerHTML =
xmlResponse.selectSingleNode("soap:Envelope/soap:Body").text ;
}
</script>