The full code would have been
index.hta
Code:
<!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" xml:lang="en" lang="en">
<head>
<HTA:APPLICATION ID="Test" APPLICATIONNAME="Test" BORDERSTYLE="normal" CAPTION="yes"
CONTEXTMENU="no" ICON="test.ico" INNERBORDER="no" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="yes" NAVIGABLE="yes" SCROLL="no"
SCROLLFLAT="no" SELECTION="no" SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" VERSION="1.0" WINDOWSTATE="" />
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"/>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<title>Test</title>
<STYLE>
<!--
-->
</STYLE>
</head>
<br />
<br />
<input id="myInfo" />
<button id="SetUpdate">Send Update to server</button>
<br />
<br />
<button id="GetUpdate">Retrieve Update from server</button>
<br />
<br />
<a href="index.hta">View Report</a>
<div id="iFrameContainer"></div>
<div id="viewer"></div>
</body>
<script type="text/javascript">
NewInfo = !1;
</script>
<script id="loadarea" type="text/javascript"></script>
<script type="text/javascript">
function ID(e){return document.getElementById(e);}
ID('SetUpdate').onclick = function(){
args = 'Arr=' + ID('myInfo').value; //Hello World';
ID('myInfo').value = '';
ID('iFrameContainer').innerHTML='<iframe style="width:0px; height:0px; border: 0px" src="http://www.mysite.com/ess/lib/testing/submit.asp?'+args+'"></iframe>';
}
ID('GetUpdate').onclick = function(){
ID('loadarea').src= 'http://mysite.com/ess/lib/testing/test.js?nocash=' + Math.random()*500;
if(NewInfo){
if(NewInfo!=='0')
ID('iFrameContainer').innerHTML='<iframe style="width:0px; height:0px; border: 0px" src="http://www.mysite.com/ess/lib/testing/submit.asp?Arr=0"></iframe>';
}
window.setTimeout(function(){
ID('viewer').innerHTML = NewInfo;
ID('viewer').innerHTML += '<br />'+ID('loadarea').src;
ID('loadarea').src= 'http://mysite.com/ess/lib/testing/test.js?nocash=' + Math.random()*500;
},500);
}
ID('loadarea').src= 'http://mysite.com/ess/lib/testing/test.js?nocash=' + Math.random()*500;
</script>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
</html>
submit.asp
Code:
<%@LANGUAGE="JavaScript"%>
<%
FromClient = new String(Request('Arr')).replace(/[^\s\.\,0-9a-zA-Z]/g,'');
fso = Server.CreateObject("Scripting.FileSystemObject");
myPath = Server.MapPath("test.js");
if(!fso.FileExists(myPath))
myfile = fso.CreateTextFile(myPath, true);
else myfile = fso.OpenTextFile(myPath , 2);
myfile.WriteLine('NewInfo = "' + FromClient + '";');
myfile.Close();
%>
This is the example that I was testing last week, it works so far...
I *did* say that I definitely recommend AJAX, but the OP asked for a sample of how to set a loop to check the server... this isn't the AJAX forum, and I never claimed my loop was asynchronous...
@Old Pedant The problem that I had with your solution (which I definitely tried first!) is that it also runs into cross domain blocking mechanisms in my test environment... no bueno...