Click here to Skip to main content
15,918,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The if condition xmlhttp.status==200 is not satisfying & i'm not getting it so please
someone tell me why this is so...
as i'm using jsp,ajax,html in the following code

JavaScript
<script type="text/javascript" language="javascript">
            var xmlhttp;
            function CreateRequest()
            {

                if(window.ActiveXObject)
                    {

                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    else if(window.XMLHttpRequest())
                        {

                            xmlhttp = new XMLHttpRequest();
                        }
            }
            function StartRequest()
            {
                CreateRequest();
                xmlhttp.onreadystatechange = callback;
                xmlhttp.open("get", "Update_Delete.jsp", true);
                xmlhttp.send(null);
            }
            function callback()
            {
                if(xmlhttp.readyState==4)
                    {
                        if(xmlhttp.status==200)
                            { alert(xmlhttp.status);
                                 document.getElementById("result").innerHTML = xmlhttp.responseText;
                            }
                    }
            }
Posted
Updated 16-Aug-13 18:25pm
v2

Can you please use any tool like Fiddler/Firebug to check the response header?

Which status code is being sent by the server?
Is it 200 or 400 or 503 or.....
 
Share this answer
 
v2
try this

JavaScript
<script type="text/javascript" language="javascript" src="jquery-1.9.1.min.js"></script>

$.ajax({async:true, url:"pageName.aspx", type:"GET", dataType:"text"}).done( function(res) {
	alert(res); 
});
 
Share this answer
 
the problem is that the server is not getting that window datatype of the xmlhttp.status so i converted it into string & it worked....
C#
var xmlHttp;
           function StartRequest()
           {
               if(window.ActiveXObject)
              {
                  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
              }else if(window.XMLHttpRequest)
                   {
                       xmlHttp = new XMLHttpRequest();
                   }
                   xmlHttp.onreadystatechange = callback;
                   xmlHttp.open("GET", "Update_Delete.jsp", true);
                   xmlHttp.send(null);
           }
           function callback()
           {
               if(xmlHttp.readyState==4)
                   {
                       var check=xmlHttp.status;
                       alert(check);

           if(check.toString()=="200")
                           {
                               alert("HI");
                              document.getElementById("results").innerHTML = xmlHttp.responseText;
                           }
                   }
           }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900