473,398 Members | 2,188 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,398 software developers and data experts.

ajax display status problem

108 100+
Hi,
I have recently been going through ajax tutorials and i came up with the following codes..I am getting my readystate to be 0 which means it is nt initialised.Why don't I get a code of 4 and what doesn the code 0 really mean? How can I solve this problem ?

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <script type="text/javascript">    
  4.         function tr(){
  5.             if (window.XMLHttpRequest)     // Object of the current windows
  6.                 { 
  7.                         xhr = new XMLHttpRequest();   alert("firefox");  // Firefox, Safari, ...
  8.                 } 
  9.             else 
  10.                  if (window.ActiveXObject)   // ActiveX version
  11.                      {
  12.                             xhr = new ActiveXObject("Microsoft.XMLHTTP");alert("IE");  // Internet Explorer 
  13.                      } alert(xhr.readyState);
  14.  
  15.                       xhr.onreadystatechange =function chk(){
  16.                             if (xhr.readyState == 4)
  17.                                 {
  18.                                       alert("I am ready");
  19.                                 } else 
  20.                                     {
  21.                                          alert("I am not ready");
  22.                                     }
  23.                     }
  24.             }
  25.  
  26. </script>
  27. </head>
  28. <body>
  29. <button onclick="tr()">tryme</button>
  30.  
  31.  
  32. </body>
  33. </html>
  34.  

Thanks in adv
Feb 22 '10 #1
1 1366
RamananKalirajan
608 512MB
The code what you have posted here is not completed one. For an Ajax statement a submission should be done. What you have did so far is creation of XMLHttpRequest object only. Using that object only you can make an Ajax call. Regarding the readstate code, following are the codes and its status

0 = uninitialized
1 = loading
2 = loaded
3 = interactive
4 = complete

Thanks and Regards
Ramanan Kalirajan
Feb 22 '10 #2

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

Similar topics

12
by: Joel Byrd | last post by:
I am making an AJAX call when any one of a number of inputs in a form (search criteria) are clicked, checked, changed, etc. When the user clicks, checks, whatever, I am trying to display a...
12
by: whreed | last post by:
I am using AJAX XMLhttprequest to request another page on form submit and I am loading that page into a span tag. My issue is that I have more js in the called page that loads a calendar on click...
13
by: adam | last post by:
Hey All, I'm relatively new to all this and any help would be appreciated. What I'm aiming to do is create a few requests, to 1. Search for a Student against XML created from the database 2. If...
8
by: Samik R. | last post by:
Hello, I am using the innerHTML property of a div placeholder to update the contents, and the HTML is provided from a perl script on the server side. The perl script gets called through AJAX when I...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
1
oranoos3000
by: oranoos3000 | last post by:
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...
3
by: fkhowaja | last post by:
i want to show the property details and there status (APPROVED, REJECTED, PENDING) the whole result is coming through ajax now i want that if i click on Approved icon or Pending icon or Rejected icon...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.