"McKirahan" <Ne**@McKirahan.comwrote in message
news:Y9******************************@comcast.com. ..
""Une bévue"" <pe*******@laponie.com.invalidwrote in message
news:1h*****************************@laponie.com.i nvalid...
i look for a simple ajax, for a beignner, able to send a request for a
text file and show its content in a <div />
Here's an example that allows the user to refresh the time
without reloading the entire page:
<html>
<head>
<title>ajaxTime.htm</title>
<script type="text/javascript">
var i = 0;
function ajaxTime() {
var sURL = "http://tycho.usno.navy.mil/cgi-bin/timer.pl?"+i++;
var oXML = new ActiveXObject("Microsoft.XMLHTTP");
oXML.open("GET",sURL,false);
oXML.send();
var sTXT = oXML.responseText;
sTXT = sTXT.substr(sTXT.indexOf("<H2>"));
sTXT = sTXT.substr(0,sTXT.indexOf("</B>"));
document.getElementById("ajaxTime").innerHTML = sTXT;
}
</script>
</head>
<body>
<a href="javascript
:ajaxTime()">What time is it?</a>
<br><br>
<div id="ajaxTime"
style="border:solid 1px black;width:480px;height:240px"
></div>
</body>
</html>
<!--
http://tycho.usno.navy.mil/cgi-bin/timer.pl
returns the following Web page:
<html>
<body>
<TITLE>What time is it?</TITLE>
<H2US Naval Observatory Master Clock Time</H2<H3>
<BR>Oct. 02, 19:04:43 UTC
<BR>Oct. 02, 03:04:43 PM EDT
<BR>Oct. 02, 02:04:43 PM CDT
<BR>Oct. 02, 01:04:43 PM MDT
<BR>Oct. 02, 12:04:43 PM PDT
<BR>Oct. 02, 11:04:43 AM AKDT
<BR>Oct. 02, 09:04:43 AM HAST
</H3></B><P><A HREF="http://tycho.usno.navy.mil">
Time Service Department, US Naval Observatory</A>
</body></html>
the following is extracted and displayed:
<H2US Naval Observatory Master Clock Time</H2<H3>
<BR>Oct. 02, 19:04:43 UTC
<BR>Oct. 02, 03:04:43 PM EDT
<BR>Oct. 02, 02:04:43 PM CDT
<BR>Oct. 02, 01:04:43 PM MDT
<BR>Oct. 02, 12:04:43 PM PDT
<BR>Oct. 02, 11:04:43 AM AKDT
<BR>Oct. 02, 09:04:43 AM HAST
</H3>
-->