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

I am trying to make Http request to one site suppose "gmail.com". Once gmail opens need to provide username ,password. then I need to get data and use it in my application. I am able to do it in Java, but my project is in MFC and I am using DHtmalDialog to use javascript. here is my code what I have wrote upto now. Please help me I am new in javascript.

// Here calling the function
httpGet("gmail.com"); // gmail is just for example

C#
function httpGet(theUrl)
       {
           var xmlHttp = null;
           xmlHttp = new XMLHttpRequest();
           xmlHttp.open("POST", theUrl, false);
           xmlHttp.setRequestHeader("username", "invalid");
           xmlHttp.setRequestHeader("password", "invalid;);
           xmlHttp.setRequestHeader("Content-Type", "application/json");
           xmlHttp.setRequestHeader("Accept", "application/json");
           xmlHttp.setRequestHeader("Accept-Encoding", "gzip,deflate");
           xmlHttp.send();
           alert(xmlHttp.readyState); // here I am getting 4
           alert(xmlHttp.status); // here I am getting 200
           alert(xmlHttp.responseText); // but here it is blank
          // xmlHttp.responseType = "json";

           if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
               alert(xmlHttp.responseText); // here also it is blank
               }
           else {
               alert("fail to get status");
           }
           return xmlHttp.responseText;
        }
Posted

1 solution

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