html не видит парсинг json в angular ниже код NAME ACCOUNT - вопрос №4553816

<!doctype html>
<html lang=«en»>
<head>
<meta charset=«utf-8»>
<title>Angularestask</title>
<base href="/">
<meta name=«viewport» content=«width=device-width, initial-scale=1»>
<link rel=«icon» type=«image/x-icon» href=«favicon.ico»>
</head>
<body>
<app-root></app-root>
</body>
</html>


import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'angularestask';
}


<div>
<table id=«table»>
<colgroup>
<col class=«name» />
<col class=«account» />
</colgroup>
<tr>
<th onclick=«sortTable(0)»><span class=«glyphicon glyphicon-sort»></span>NAME</th>
<th onclick=«sortTable(1)»><span class=«glyphicon glyphicon-sort»></span>ACCOUNT</th>
</tr>
</table>
</div>
<script>
document.addEventListener( «DOMContentLoaded», get_json_data, false ); // get_json_data is the function name that will fire on page load

function get_json_data(){
var json_url = 'data.json';
print(json_url.toString());

xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {//when a good response is given do this

var data = JSON.parse(this.responseText); // convert the response to a json object
append_json(data);// pass the json object to the append_json function
}
}
//set the request destination and type
xmlhttp.open(«POST», json_url, true);
//set required headers for the request
xmlhttp.setRequestHeader(«Content-type», «application/x-www-form-urlencoded»);
// send the request
xmlhttp.send(); // when the request completes it will execute the code in onreadystatechange section
}

[
{
«name»: «user0»,
«account»: "$2,253.11"
},
{
«name»: «user1»,
«account»: "$1,715.95"
},
{
«name»: «user2»,
«account»: "$2,777.94"
},
{
«name»: «user3»,
«account»: "$2,144.61"
},
{
«name»: «user4»,
«account»: "$2,549.41"
},
{
«name»: «user5»,
«account»: "$1,947.58"
},
{
«name»: «user6»,
«account»: "$3,879.91"
},
{
«name»: «user7»,
«account»: "$3,212.70"
},
{
«name»: «user8»,
«account»: "$2,578.87"
}
]
28.11.21
0 ответов
Ответов пока нет

Глеб Черняк

от 55 p.
Читать ответы

Олег Николаевич

от 50 p.
Читать ответы

Alexander

от 500 p.
Читать ответы
Посмотреть всех экспертов из раздела Технологии
Пользуйтесь нашим приложением Доступно на Google Play Загрузите в App Store