Answer the question
In order to leave comments, you need to log in
How to convert the API to normal?
Tell me how to convert the API to normal ?
I get the API in this way:
<html>
<head>
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
jsonObject = JSON.parse(this.responseText);
document.getElementById('output').innerHTML = JSON.stringify(jsonObject, undefined, 4);
}
};
xhttp.open("GET", "/api.php/records/users", true);
xhttp.send();
</script>
</head>
<body>
<pre id="output"></pre>
</body>
</html>
{
"records": [
{
"id": "1",
"name": "Владислав",
"birthday": "18.04.1996",
},
{
и т.п.
Answer the question
In order to leave comments, you need to log in
For example in a loop:
var html = ''
for (let key in jsonObject.records) {
html += '<p>';
html += 'Имя:' + jsonObject.records[key].name;
html += '</p>';
}
document.getElementById('output').innerHTML = html;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question