How to alert the div to display?

the <script>
// This is the json which came
var json = '<?php echo $s;?>';
// Here parsim json
var data = JSON.parse( json );

// Here we get the desired property
alert( data.icestats.source.title );
</script>

in the pop-up browser window showing the contents of the brackets alert, how to display div and paste to the page in the right place?
June 8th 19 at 17:12
2 answers
June 8th 19 at 17:14
Solution
You want the contents of the alert to add to the block on the page?
If the block has already been created, for example, that pure js:
<div id="div-name"></div>
the <script>
var myDiv= document.getElementById('div-name'), 
json = '<?php echo $s;?>',
data = JSON.parse( json );

myDiv.innerHTML = data.icestats.source.title;
</script>

Jquery:
$('#div-name').html(data.icestats.source.title);
which block?
apparently not
I do not know)
I'm lower on the page created divco with the class .div-name and all - Nedra3 commented on June 8th 19 at 17:17
you have jquery running?
If Yes, then after
data = JSON.parse( json );
add:
$('.div-name').html(data.icestats.source.title);
And on the page with the div class-name should appear contents. - citlalli65 commented on June 8th 19 at 17:20
June 8th 19 at 17:16
As far as I know(could be wrong), alert cannot be taken in blocks

Find more questions by tags JavaScript