What does status 0 in ajax mean?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpuser123
    New Member
    • Dec 2009
    • 108

    What does status 0 in ajax mean?

    Code:
    <html>
    <head>
    		<script type="text/javascript" src=ajax.js></script>
    		
    		</script>
    		<style type='text/css'>
    		</style>
    	</head>	
    	<body onload='makePOSTRequest("video_videos.php","display_details")'>
    <div id='display_details'></div>
    </body>
    </html>
    My ajax func is defined in an external file ajax.js
    Code:
    function makePOSTRequest(filename,id)
    			{
    				if (window.XMLHttpRequest)     // Object of the current windows
    				{ 
       					 xhr = new XMLHttpRequest();   
    				} 
    			else 
    				 if (window.ActiveXObject)   // ActiveX version
    					 {
      						  xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
     					} 
    			
    			  xhr.onreadystatechange =function chk()
    					{alert(xhr.status);
    							
    						if (xhr.readyState == 4){
    							
    							if (xhr.status==200){
    									
    									document.getElementById(id).innerHTML=xhr.responseText;	
    									alert(xhr.responseText);
    								}
    								}
    							
    					}
    			xhr.open('GET', filename, true);                  
    		xhr.send(null); 
    		
    					}
    I just implemented a small script for ajax and when i rin it I get the status to be 0.
    What does that mean?
    Last edited by Dormilich; Apr 26 '10, 07:40 PM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    in case of .status, the local file system does not send HTTP status codes, thus 0.

    the .readyState 0 means "unsent"

    Comment

    • phpuser123
      New Member
      • Dec 2009
      • 108

      #3
      Is there any way to debug the status 0..I've been getting this a couple of times
      ...

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        you (resp. the XMLHttpRequest object) will go through each readyState, no need to debug something. besides, you can only get a HTTP status code, if the server responds (that is, not before readyState 2) and I would only be concerned if the status is not 200 or 0.

        Comment

        Working...