473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem in read content file on the server with ajax

oranoos3000
107 100+
hi
i have a script that with click a button in this script text with id="targetDiv"
is substitute with content of the file data.txt.
this script and data.txt are on the same directory on my local disk
my problem is that with pressing button on this script this is not substituted
and XMLHttpRequestObject.status instead of 200 is 0
what is meaning of XMLHttpRequestObject.status instead equal to zero?
how can i change XMLHttpRequestObject.status to 200?

my script is:

Expand|Select|Wrap|Line Numbers
  1. <html> 
  2.   <head> 
  3.     <title>Ajax at work</title> 
  4.  
  5.     <script language = "javascript">
  6.       var XMLHttpRequestObject = false; 
  7.  
  8.       if (window.XMLHttpRequest) {
  9.         XMLHttpRequestObject = new XMLHttpRequest();
  10.       } else if (window.ActiveXObject) {
  11.         XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  12.       }
  13.  
  14.       function getData(dataSource, divID) 
  15.       { 
  16.         if(XMLHttpRequestObject) {
  17.           var obj = document.getElementById(divID); 
  18.           XMLHttpRequestObject.open("GET", dataSource); 
  19.  
  20.           XMLHttpRequestObject.onreadystatechange = function() 
  21.           { 
  22.             if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { 
  23.                 obj.innerHTML = XMLHttpRequestObject.responseText; 
  24.             } 
  25.           } 
  26.  
  27.           XMLHttpRequestObject.send(null); 
  28.         }
  29.       }
  30.     </script>
  31.   </head> 
  32.  
  33.   <body>
  34.  
  35.     <H1>Fetching data with Ajax</H1>
  36.  
  37.     <form>
  38.       <input type = "button" value = "Display Message" onclick = "getData('data.txt', 'targetDiv')"> 
  39.     </form>
  40.  
  41.     <div id="targetDiv">
  42.       <p>The fetched data will go here.</p> 
  43.     </div> 
  44.  
  45.   </body> 
  46. </html>
my browser is internet explorer 4.0
and i run this script on windows NT 5.1
thanks very much
Jul 11 '09 #1
1 1619
Dormilich
8,658 Expert Mod 8TB
@oranoos3000
are you sure that IE 4 actually supports AJAX? I mean, IE 6 is still a programmer's nightmare but IE 4… that's more than 10 years ago (and personally I didn't expect it to be used any more)
Jul 12 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: greenb | last post by:
Our asp.net web app uses a .NET component (DLL) in the bin directory to call several stored procedures back to back to perform updates. They don't return any data. Sometimes the total execution...
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
2
by: Alex | last post by:
Example uploaded to: http://www.clickatus.com/ajax/ BTW - This is for FIREFOX, won't work in IE. I don't know why but when it is executed the browser still in loading state... Even though...
1
by: JohnnieTech | last post by:
I am using some javascript/ajax to load content into a main div. The problem I am running into is that it will work in IE but not in FF. In FF I don't get any sort of load at all. I have a 1...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
1
by: hesameagle | last post by:
Hi I want to use ajax to connect to database and echo some data in my page, I wrote these two codes that can handle my need: index.php ----------------------------------------- <?php ...
12
by: sheldonlg | last post by:
Here is my situation. I am coding in an AJAX framework for an intranet application behind a vpn. Therefore, I can't give you a URL for the actual app. I made a sample app for viewing and am...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.