By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

problem in read content file on the server with ajax

oranoos3000
100+
P: 107
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
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
@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

Post your reply

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