I hope all is well and I appreciate if you can help me or re-direct me to a similar old post because I couldn't find one.
I'm trying to initiate a REST API request and the server will send a JSON response. The request works find but I'm unable to read the JSON output. The status always returns 0.
Here is my code.
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "URL HERE", true);
xhttp.setRequestHeader("Content-type", "application/json")
xhttp.send();
var response = JSON.parse(xhttp.responseText);
document.getElementById("demo").innerHTML = response.Result;
}
</script>
I want to print this JSON's result:
{
Meta: {
Status: 'Success',
Debug: ''
},
Result: {
Count: 2584,
Error: [],
Info: [],
Skipped: [],
DuplicateResponseCount: 0,
DuplicateError: null
}
}
Thanks a lot.