I have created a file that automatically posts 3 identification fields (for authentication) to retrieve JSON results. It works fine (right now developed as proof of concept so ids are hard-coded). Upon success, the JSON is returned as an alert to the browser.
How can I return and format the JSON results on the screen?
Here is the working url: https://www.advantageengagement.com/REST/js_yes.html
<!DOCTYPE html>
<html>
<head>
<title>Javascript POST Form</title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var http = new XMLHttpRequest();
var postdata= "id_eap=999&id_company=&password=AAA111BBB2";
http.open("POST", "https://www.advantageengagement.com/REST/content/read.php", true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(postdata);
</script>
</body>
</html>