Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

While trying to Display "xmlhttp.responseText" Its returning HTML PAge. I want string data to be displayed.
PLease help
My code :

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

    xmlhttp.onreadystatechange = function () {
       
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

             alert(xmlhttp.responseText); //This is showing Result as HTML PAGE
            var response = eval('(' + xmlhttp.responseText + ')');
            
            var status = " ";
            if (response.Data.length != 0) {
                
                for (var i = 0; i < response.Data.length; i++) {

                    for (var value in response.Data[i]) {
                        status = status + "<option value=" + response.Data[i][value] + ">" + response.Data[i][value] + "</option>";
                    }

                }
            }
            else {
                
            }
            $("#ddItem").html(status);
            $("select#ddItem").selectmenu("refresh");
            
           
        }

        else if (xmlhttp.status != 200) {

            navigator.notification.alert("Coudn't connect to the server,Please check your internet settings or contact system administrator!", null, 'Connection Failed', 'OK');
        }
    }

    var key = window.localStorage.getItem("userkey");
    var clientid = window.localStorage.getItem("clientid");
    var url = clientid + "/GetInventory";
    xmlhttp.open("POST", url, true);
    xmlhttp.timeout = 10000;
    xmlhttp.ontimeout = function () { $.mobile.loading("hide"); navigator.notification.alert("Coudn't connect to the server,Please check your internet settings or contact system administrator!", null, 'Timed Out', 'OK'); }
    xmlhttp.send("key=" + key);
Posted
Updated 30-Oct-13 22:41pm
v6
Comments
Richard MacCutchan 30-Oct-13 13:44pm    
alert(xmlHttp.responseHTML); //This is showing Result as HTML PAGE
Shouldn't that be responseXML?
Ramkumar K 31-Oct-13 4:40am    
That is actually "xmlhttp.responseText"
Richard MacCutchan 31-Oct-13 4:53am    
Then it's working correctly, see the documentation for full details.
Ramkumar K 31-Oct-13 5:34am    
It should work,, but it doesn't . Dont know why?..

Richard MacCutchan,Thanks for your reply.
Richard MacCutchan 31-Oct-13 5:43am    
Have you tried responseXML?

1 solution

Sorry Guys.. Its my Foolish Mistake.. i have given wrong URL.. After Changing to Correct URL. It Worked..
 
Share this answer
 
v2

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



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