UPDATE - I have the following page. It's working in Chrome and Firefox, but I also need it to work in IE 11. I can not use jQuery - just plain javascript. Can anyone provide any help? I have changed the api url to a fake one. I'd really appreciate any help - not the greatest at Javascript. It does seem to choke on the following line: res.results.map(f => {
I do not know what to change this line to make it work. Like I said - not much experience with javascript. Any help would be appreciated.
<html>
<head>
</head>
<body>
<div class="wrapper">
<div class="profile">
<table id= "userdata" border="2">
<thead>
<th>Organization</th>
<th>Service</th>
<th>URL</th>
<th>Account Created</th>
<th>ID</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
(function() {
var table = document.getElementById("userdata");
var people = [];
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var res = JSON.parse(this.responseText);
console.log(res.results);
res.results.map(f => {
var tblRow = "<tr>" + "<td>" + f.account + "</td>" +
"<td>" + f.service_key + "</td>" +
"<td>" + f.service_url + "</td>" + "<td>" + f.created_at + "</td>" + "<td>" + f.id + "</td>" + "</tr>";
table.innerHTML += tblRow;
});
}
};
xhttp.open("GET", "https://jsonplaceholder.typicode.com/posts/1", true);
xhttp.send();
})();
</script>
</body>
</html>
UPDATE - I replaced that line with function(f) and now its saying unexpected token:
<html>
<head>
</head>
<body>
<div class="wrapper">
<div class="profile">
<table id= "userdata" border="2">
<thead>
<th>Organization</th>
<th>Service</th>
<th>URL</th>
<th>Account Created</th>
<th>ID</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script>
(function() {
var table = document.getElementById("userdata");
var people = [];
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var res = JSON.parse(this.responseText);
console.log(res.results);
function(f) {
var tblRow = "<tr>" + "<td>" + f.account + "</td>" +
"<td>" + f.service_key + "</td>" +
"<td>" + f.service_url + "</td>" + "<td>" + f.created_at + "</td>" + "<td>" + f.id + "</td>" + "</tr>"
table.innerHTML += tblRow;
});
}
};
xhttp.open("GET", "https://jsonplaceholder.typicode.com/posts/1", true);
xhttp.send();
})();
</script>
</body>
</html>