473,698 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading a file on the server - timing issues?

joe
I am loading a text file to a variable with XMLHttpRequest( )
There seems to be some sort of timing issue since loadXML (source code below)
returns the contents of the file on seconds try. In Firefox I get an empty
string. No errors are reported.

If I look at the code with Firefox debugger (Venkman) everything works fine. I
should probably put a loop somewhere to check when loading the file is finished.
var xmlhttp;
...
[a lot of Javascipt code here]
...
loadXMLDoc("htt p://wwww.mysite.com/test.bin");
mystr=xmlhttp.s tatusText;
...
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttp Request)
{// code for IE7, Firefox, Opera, etc.
xmlhttp=new XMLHttpRequest( );
}
else if (window.ActiveX Object)
{// code for IE6, IE5
xmlhttp=new ActiveXObject(" Microsoft.XMLHT TP");
}
if (xmlhttp!=null)
{
xmlhttp.onready statechange=sta te_Change;
xmlhttp.open("G ET",url,true) ;
xmlhttp.send(nu ll);
}
else
{
alert("Browser not supported.");
}
}

function state_Change()
{
if (xmlhttp.readyS tate==4)
{// 4 = "loaded"
if (xmlhttp.status !=200)
{
alert("Problem: " + xmlhttp.statusT ext);
}
}
}
Jun 27 '08 #1
2 1290
joe wrote:
loadXMLDoc("htt p://wwww.mysite.com/test.bin");
mystr=xmlhttp.s tatusText;
As your loadXMLDoc does asynchronous loading (third argument to open
method is true) you can't access the statusText in your code following
the loadXMLDoc call as that code is executed before the response to the
HTTP request will have been received.
Continue to use asynchronous loading but put any code trying to read
status, statusText and responseXML or responseText into the
onreadystatecha nge handler.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
joe
Martin Honnen <ma*******@yaho o.dewrote:
>joe wrote:
>loadXMLDoc("ht tp://wwww.mysite.com/test.bin");
mystr=xmlhttp. statusText;

As your loadXMLDoc does asynchronous loading (third argument to open
method is true) you can't access the statusText in your code following
the loadXMLDoc call as that code is executed before the response to the
HTTP request will have been received.
Continue to use asynchronous loading but put any code trying to read
status, statusText and responseXML or responseText into the
onreadystatech ange handler.
Thanks. It helped.
Jun 27 '08 #3

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

Similar topics

1
1560
by: staleb | last post by:
Hi My problem is like this: I have a file-server and a web-server. How do I display images that r stored on the file-server. The users only have dircet access to web-server. When I display the images with an <img=..... I only get the direct path to the file-server. PS uploading the files works fine. But not dispalying them
3
1578
by: swingingming | last post by:
Hi, for 5 weeks, I finished my mdb project. Thanks to all you guys. Now, I would like to put it on a server then 5-6 people can share it. I heard about the splitting back-end database, put it on a file server or DB server. Then install the front-end on every client machine. And clients must be able to connect to the backend remotely. Should I use something like SQL server/MSDE or just a file server? If I use MSDE, will I rewrite all the...
3
1673
by: Doug | last post by:
I have a split Access database that resides on a file server. The file server is a restricted drive that only people with the correct permissions can browse to this directory on the LAN. Several users use the Access front end to modify the database on the file server, but I would like to make some of the data available (read-only) through webpages with asp. It is not an option to move the database directly to the webserver because these...
2
1585
by: lawrence | last post by:
I have a web server running IIS pointing to a file server. Should the ..NET framework be installed on both the web server and the file server? Right now I have it installed on only the web server. <script> aspx pages work, but I cant deploy Web applications --get a "can't load namespace.global" error in the global.asax. I xcopied all the files and the bin/dll. Thanks
1
1875
by: Matt Hamilton | last post by:
I was hoping that someone can give me step-by-step instructions to fix the following: We would like our ASP.NET application to utilize a central file server for uploads and downloads. I have tried creating a virtual directory to the external file server on the web server and just referencing the virtual directory when setting a hyperlink to download a file and everything seems to work well until I attempt to implement an HTTPHandler (to...
4
8047
by: RLN | last post by:
Re: Access 2003/WinXP Pro-SP3 I have a shell command that does not run correctly. I have two programs located on a file server: Pgm1.mdb and Pgm2.mdb Pgm1 launches Pgm2 via a command button using a shell command. The old method ran fine when the specified file server was mapped on the user's workstation as a drive letter (U) strAppName = "msaccess.exe " & "U:\Access_EQ\EQ-NonCorp.MDB"
6
2833
by: Marc Castrechini | last post by:
This is a classic double hop delegation issue, however its the first time we are setting this up so we are doing something incorrectly. If we run through the IDE or using a localhost path on the web server the command succeeds. However, if we use the servername or ip through IIS it fails. For this reason we know we have permissions setup correctly on the file server. Can anyone identify what we could possibly be doing wrong here: ...
9
3007
by: TC | last post by:
Like a lot of database developers, I often choose Jet for the back- end. I'm starting to worry about what will happen when Jet is deprecated. Ostensibly, Jet users like me must switch to SQL Server (or MSDE / SQL Express), but there's something I just don't understand. Without Jet, how will we create file server database applications? In other words, how will we create multi-user apps which use a file server to share data and don't...
0
5310
harshadd
by: harshadd | last post by:
Dear all, I am trying to install File server Resource Manager to apply user level directory quota. Tried to use this link for help , it is as below: I checked the GIF file But on my server I can not see item no 3 & 4 . ie File server management & File server resource manager
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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
9157
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...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
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,...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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();...
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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.