M
Mike Duffy
After reading up a bit on Ajax, decided to try out a simple test script.
It works with IE (8), but not FF (3.5.3). I might add support for other
browsers later using the try..catch techniques that are well-documented
elsewhere, but that would be pointless to try when I cannot correctly
write the absolute simplest example I could think of, which was to take
the jibbering example and then change it to point to my own server.
In effect, I was looking for a script to tell me the server time, because
their clock is always several minutes slow and I need to know how many
minutes I need to wait after uploading a file before my new documents get
treated as being more recent than the ones in the various server cache
proxies.
When I run it with FF, it does not look like the callback is ever
executed. It just sits there. I have looked at dozens of ajax tutorial
sites, and they all boil down to the following code when you take away
the support for old browsers.
And I am using the index page of my website as the Ajax target, because
if I use a 3rd party site, IE gives me the warning about mixing secure /
insecure items.
<html lang="en">
<head>
<title>Test Server Time</title>
</head>
<body onLoad="test()">
<script type="text/javascript">
function test() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("HEAD", "http://pages.videotron.com/duffym/index.htm",
false);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.write('Time at server: ' + xmlhttp.getResponseHeader('Date'))
};
}
xmlhttp.send(null);
}
</script>
</body>
</html>
It works with IE (8), but not FF (3.5.3). I might add support for other
browsers later using the try..catch techniques that are well-documented
elsewhere, but that would be pointless to try when I cannot correctly
write the absolute simplest example I could think of, which was to take
the jibbering example and then change it to point to my own server.
In effect, I was looking for a script to tell me the server time, because
their clock is always several minutes slow and I need to know how many
minutes I need to wait after uploading a file before my new documents get
treated as being more recent than the ones in the various server cache
proxies.
When I run it with FF, it does not look like the callback is ever
executed. It just sits there. I have looked at dozens of ajax tutorial
sites, and they all boil down to the following code when you take away
the support for old browsers.
And I am using the index page of my website as the Ajax target, because
if I use a 3rd party site, IE gives me the warning about mixing secure /
insecure items.
<html lang="en">
<head>
<title>Test Server Time</title>
</head>
<body onLoad="test()">
<script type="text/javascript">
function test() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("HEAD", "http://pages.videotron.com/duffym/index.htm",
false);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.write('Time at server: ' + xmlhttp.getResponseHeader('Date'))
};
}
xmlhttp.send(null);
}
</script>
</body>
</html>