статусная страница io json parse - PullRequest
0 голосов
/ 09 января 2019

Я просто хочу вывести текст из файла JSON в HTML, API здесь: https://shopify.statuspage.io/api

function setup() {
  loadJSON("https://d33g96wd23dd.statuspage.io/api/v2/summary.json", gotData, 'jsonp');
}

function gotData(data) {
  var output = document.getElementById('output');
  output.innerHTML = data.status + ' ' + data.description;
}
<div class="w3-container w3-center" id="output"></div>

1 Ответ

0 голосов
/ 09 января 2019

Вы можете использовать приведенный ниже код, если хотите визуализировать первый элемент массива

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var output = document.getElementById('output');
  $.getJSON( "https://d33g96wd23dd.statuspage.io/api/v2/summary.json", function( data ) {

  output.innerHTML = data.components[0].status + ' ' + data.components[0].description;
});
});

</script>
</head>
<body>

<div class="w3-container w3-center" id="output"></div>

</body>
</html>

иначе вы можете поочередно зацикливать ваш метод добавления.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...