I'm curious about how to verify the status of an xmlHttp request once it has been sent. Can someone explain the process to me? Thank you.
function sendRequest(){
//retrieve access token
var accessToken = 'xxx';
//get user_id
var userid = document.getElementById('userid').value;
//retrieve request_token
var requestToken = document.getElementById('requestToken').value;
//insert into database
var xmlHttp = new XMLHttpRequest();
var url="database.php";
var parameters = "accessToken=" + accessToken + "&userid=" + userid + "&requestToken=" + requestToken ;
xmlHttp.open("POST", url, true);
//send request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", parameters.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(parameters);
//check status
if(xmlHttp.status == Ok){
alert('Success!');
}else {
alert('Error');
}
}