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

xmlhttprequest http.status unknown

P: 25
I am having a problem getting the http.status of an xmlhttprequest. The request readystate has come back as readystate 4, but then it stops without confirming the http.status. Any help appreciated.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" >
  2. var postring = "?";
  3. function string()
  4.     {
  5.         var first = document.numbers.first.value;
  6.         var second = document.numbers.second.value;
  7.         var third = document.numbers.third.value;
  8.         postring += "first=" + first + "&second=" + second + "&third=" + third;
  9.         alert(postring);
  10.         insert();
  11.     }
  12. function insert(url)
  13.     {
  14.     var url="http://localhost/Project/Hi.php";
  15.         var http;
  16.  
  17.         if (window.XMLHttpRequest) 
  18.         { // Mozilla, Safari, ...
  19.             http = new XMLHttpRequest();
  20.             if (http.overrideMimeType) 
  21.             {
  22.                 http.overrideMimeType('text/xml');
  23.                 // See note below about this line
  24.             }
  25.         } 
  26.         else if (window.ActiveXObject) 
  27.         { // IE
  28.             try {
  29.                 http = new ActiveXObject("Msxml2.XMLHTTP");
  30.                 } 
  31.                 catch (e)
  32.                 {
  33.                  try {
  34.                       http = new ActiveXObject("Microsoft.XMLHTTP");
  35.                       } 
  36.                  catch (e) {}
  37.                 }
  38.         }
  39.         if (!http) 
  40.         {
  41.             alert('Giving up :( Cannot create an XMLHTTP instance');
  42.             return false;
  43.         }
  44.         alert('ok');
  45.         http.onreadystatechange = function()
  46.         {
  47.         if (!http.readyState)  
  48.             {
  49.                alert('There was a problem with the request.');
  50.             }
  51.         else
  52.         alert(http.readyState);
  53.         if (http.readystate == 4)
  54.             {
  55.             alert(http.Status);
  56.             if (http.Status ==  200)
  57.                 {
  58.                 response = http.responseText;
  59.                 alert(response);
  60.                 document.numbers.first.value = "";
  61.                 document.numbers.second.value = "";
  62.                 document.numbers.third.value = "";
  63.                 }
  64.             }
  65.         }
  66.         http.open('POST', url+postring, true);
  67.         http.send('');
  68.     }
  69. </script>
  70.  
Aug 21 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Heya, rpjd.

Is it http.Status, or http.status?
Aug 21 '07 #2

Post your reply

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