Tuesday, May 28, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  12] [ 2]  / answers: 1 / hits: 8234  / 8 Years ago, sat, june 11, 2016, 12:00:00
<html>
<body>
<div id=output>hi</div>
</body>
<script>
var link=http://mywp.com/cilacap/api/get_posts/;
var jcontent= JSON.parse(link);
var output=document.getElementById('output');
output.innerHTML=jcontent.id' ';
</script>

</html>


It only shows hi.
Can someone tell me how to show JSON items such as id and postDate
with looping but without PHP scripting?



Thanks


More From » html

 Answers
2

Few syntactical errors, below is the right one.





<html>
<body>
<div id=output>hi</div>
</body>
<script>
var link='{url:http://mywp.com/cilacap/api/get_posts/, id:url_id_01}';
var jcontent= JSON.parse(link);
var output=document.getElementById('output');
output.innerHTML=jcontent.id + ' ';
</script>

</html>





JSON Data(var link), was not parsable.



JSON Data(var link), didnt contained any attribute called id.



String concatenation in last line(output.innerHTML), was wrong.


[#28120] Thursday, June 9, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janeth

Total Points: 498
Total Questions: 91
Total Answers: 89

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
;