I'm trying to get an Xmlhttp.response from a website, specifically with this part of code:
var apiUrl = "http://somesite/someapicall/correctapiKey";
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", apiUrl, false);
xmlHttp.setRequestHeader("Content-Type", "application/json");
var data {
"username": username,
"password": hashedPass,
"someOption": "true",
"someOtherOption": "true"
}
xmlHttp.send(data);
var response = xmlHttp.responseText;
var parsed = eval('(' + response + ')');
If i put in the actual strings in "username": & "password" instead of using the variables the code does work. with the variables it fails.
I'm probably missing something small again, but i really can't see it and i'm breaking my head over it since this afternoon :(
anyone ? please...
edited: the username and the hashed pass are given as variables with known correct values. changed the code to reflect the use of the variables
=in your assignment ofvar data.eval()to parse JSON.