473,804 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xmlhttp request executed before getting the objects

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(xml http, dt, day) {
var date = dt.getDate() + '.' + (dt.getMonth()+ 1) + '.' +
dt.getYear();
xmlhttp.open("H EAD", "diary/" + date + ".htm",fals e);
xmlhttp.onready statechange=fun ction() {
if (xmlhttp.readyS tate==4) {
if (xmlhttp.status ==0 || xmlhttp.status= =200){
..........
document.all.co ntent.src = "diary/" + date + ".htm";
document.getEle mentById(day).i nnerHTML= date;
document.getEle mentById("image ").innerHTM L= '<img src="images/' +
date +

'.jpg" height="150" width=150" name="u"
style="filter:a lpha(opacity=0) ">';
window.clearInt erval(window.ti merID);
window.timerID= window.setInter val("JM_fade(u,
document.frames ('content').doc ument.body)",5) ;
........
}
............... .......
xmlhttp.send(nu ll);
}

Marco

Mar 26 '07 #1
1 1586
On Mar 26, 9:55 am, tsangkin...@gma il.com wrote:
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(xml http, dt, day) {
var date = dt.getDate() + '.' + (dt.getMonth()+ 1) + '.' +
dt.getYear();
xmlhttp.open("H EAD", "diary/" + date + ".htm",fals e);
xmlhttp.onready statechange=fun ction() {
if (xmlhttp.readyS tate==4) {
if (xmlhttp.status ==0 || xmlhttp.status= =200){
.........
document.all.co ntent.src = "diary/" + date + ".htm";
document.getEle mentById(day).i nnerHTML= date;
document.getEle mentById("image ").innerHTM L= '<img src="images/' +
date +

'.jpg" height="150" width=150" name="u"
style="filter:a lpha(opacity=0) ">';
window.clearInt erval(window.ti merID);
window.timerID= window.setInter val("JM_fade(u,
document.frames ('content').doc ument.body)",5) ;
.......
}
............... .......
xmlhttp.send(nu ll);

}

Marco
Call your showContent function (or some other function that calls
showContent) from the onload event handler of the document body. This
method gets called after the body has been loaded.

<body onload="your_fu nction();">

Mar 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3262
by: Irene | last post by:
Hi, I have an asp page that allows a user to search for info in a DB and add info to a DB. The search uses "ADODB.Connection" objects in the page, but the add will use a call to an isapi dll via the "Microsoft.XMLHTTP" object. The results of the isapi dll will be displayed to the user without refreshing the asp page. I have a code snippet below for the isapi call. WHat is happening is that the xmlhttp.responseText from the snippet...
6
3267
by: Krzysztof Kubiak | last post by:
I'm trying to make use of XMLHTTP object, but I've come across a problem. It seems that there is no way to create dynamic array of such XMLHTTP objects (to make several requests) and handle them properly. I was trying to use such code: <script lang="javascript"> function handleOnReadyStateChange() { if (this.readyState==4) {
3
1993
by: kajol | last post by:
Hi everyone I am trying to get the content of any webpage (URL) using XMLHTTP, and it is working fine for me, but suddenly I have got a URL "http://www.bizrate.com/" which is causing a system error and the error is System.Runtime.InteropServices.COMException(0xC00CE56E): System error:- 1072896658
10
4889
by: sneill | last post by:
Using XMLHTTP and DOM I'm able to load new HTML page content. I'd now like to load small snippets of javascript with the HTML markup and have that <script> incorporated into the page. If any of the loaded script exists outside a function definition (eg: a call to a function), I'd like that code to be executed as soon as its added to the DOM. Can anyone suggest the best way to do this? I've Googled but not found anything comprehensive....
6
10460
by: Vanessa | last post by:
I have a question regarding async mode for calling Microsoft.XMLHTTP object. Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work again after half an hour or so without doing anything. I have searched through the Internet and seems like the reason it hangs the browser it's because XMLHTTP limits you to two concurrent HTTP connections to each remote host; so if more than 2 concurrent connections strike the script...
9
2386
by: balakrishnan.dinesh | last post by:
hi friends, Exactly what i want to know is, In my product we are using xmlhttp request to retrive some data from the server, And Im using IE browser, its working fine in IE. Now i want to work with netscape,I dont know how to pass the xmlhttp request in Netscape. i got some code like below for netscape for xmlhttp var oXML=new XMLHttpRequest();
14
10023
by: FMDeveloper | last post by:
Currently transitioning from a shared host to a dedicated server. The same code that works on the old server is not working on the dedicated server. It is a simple AJAX request like: <code> function createXMLHttpRequest() { if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) {
4
8286
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my problems and this one is really getting to me... I have a page that allows you to Browse Authors. There are three drop down boxes that auto-populate via AJAX. I have a file which it calls and returns the dynamically built XML file in the boxes...
2
12476
by: trpost | last post by:
Is it possible to execute javascript as passed in xmlHttp.responseText Here is what I am doing: search.js var xmlHttp xmlHttp=GetXmlHttpObject() var url="search.php" xmlHttp.onreadystatechange=stateChanged
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.