P
P
prrrrrrr2019-04-23 17:51:48
API
prrrrrrr, 2019-04-23 17:51:48

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>

I get the result:
{
    "records": [
        {
            "id": "1",
            "name": "Владислав",
            "birthday": "18.04.1996",
        },
        {
и т.п.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Gololobov, 2019-04-23
@prrrrrrr

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;

G
GrimJack, 2017-03-16
@GrimJack

API version, right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question