T
tsangkinyip
Hi there,
I have a diary page where I would like to fade in the text content and
an image when a user tries to click on a date in the calendar. Things
work fine offline, but when I upload the files to the server I've
found that the server is much slower than I've thought and the xmlhttp
request has been executed before getting the image and body objects,
which leads to a javascript error. May I ask what I can do to solve
the problem? Thanks in advance.
function showContent(xmlhttp, dt, day) {
var date = dt.getDate() + '.' + (dt.getMonth()+1) + '.' +
dt.getYear();
xmlhttp.open("HEAD", "diary/" + date + ".htm",false);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status==0 || xmlhttp.status==200){
..........
document.all.content.src = "diary/" + date + ".htm";
document.getElementById(day).innerHTML= date;
document.getElementById("image").innerHTML= '<img src="images/' +
date +
'.jpg" height="150" width=150" name="u"
style="filter:alpha(opacity=0)">';
window.clearInterval(window.timerID);
window.timerID=window.setInterval("JM_fade(u,
document.frames('content').document.body)",5);
........
}
......................
xmlhttp.send(null);
}
Marco
I have a diary page where I would like to fade in the text content and
an image when a user tries to click on a date in the calendar. Things
work fine offline, but when I upload the files to the server I've
found that the server is much slower than I've thought and the xmlhttp
request has been executed before getting the image and body objects,
which leads to a javascript error. May I ask what I can do to solve
the problem? Thanks in advance.
function showContent(xmlhttp, dt, day) {
var date = dt.getDate() + '.' + (dt.getMonth()+1) + '.' +
dt.getYear();
xmlhttp.open("HEAD", "diary/" + date + ".htm",false);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status==0 || xmlhttp.status==200){
..........
document.all.content.src = "diary/" + date + ".htm";
document.getElementById(day).innerHTML= date;
document.getElementById("image").innerHTML= '<img src="images/' +
date +
'.jpg" height="150" width=150" name="u"
style="filter:alpha(opacity=0)">';
window.clearInterval(window.timerID);
window.timerID=window.setInterval("JM_fade(u,
document.frames('content').document.body)",5);
........
}
......................
xmlhttp.send(null);
}
Marco