Console.log到Document.write

时间:2019-06-19 05:57:44

标签: javascript php json

在主显示屏上显示console.log文件。 document.write出了问题

这是网址数据

[{"call_time":"0","total_inc_traffic":"1363.10","total_out_traffic":"88.70"},{"call_time":"1","total_inc_traffic":"479.57","total_out_traffic":"36.98"},{"call_time":"2","total_inc_traffic":"239.57","total_out_traffic":"13.43"},{"call_time":"3","total_inc_traffic":"190.28","total_out_traffic":"8.20"},{"call_time":"4","total_inc_traffic":"223.80","total_out_traffic":"0.00"},{"call_time":"5","total_inc_traffic":"158.87","total_out_traffic":"19.58"}]

这是脚本代码:

<script>
    var ourRequest =new XMLHttpRequest();
    ourRequest.open('GET','http://localhost/icx/test/link.html');
    ourRequest.onload = function(){
      var ourData = JSON.parse(ourRequest.responseText);

    let result = ourData.map(v => Number(v.call_time));
    console.log(result);

    };
    ourRequest.send();

</script>

如何在主显示中显示结果?不在控制台中

0 个答案:

没有答案