[1130] <html> <head> <style> </style> </head> <body> <div id="b"> </div> </body> <script s...

211 Conversations | 2,776 Posts + (501 from users, 2,275 from bots) | 4 Uploaded Images +

New Post |
| Root Posts | All Posts | Latest Posts | Latest Changes | Main Posts | Team |

By Kritishankar02. Created 2020/10/27 07:50:02, modified 2020/10/29 12:47:09

Post type: HTML

Show as HTML page | Reply | Duplicate | Rename | Raw Text

<html>
<head>
<style>
</style>
</head>
<body>
	<div id="b">
	
	</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
	$.ajax({
	url:"https://jsonplaceholder.typicode.com/posts",
	type:"GET",
	success:function(data){
		for (x of data) {
		var y = [];
		var m="";
		$("#b").append("<ul><li>"+x.id+"</li>");
		m = refun(x);
		$("#b").append(m+"</ul><br>");
} 
	}
	});
});
function refun(data){
	var str = "<ul style='list-style-type:square;'>";
	for([x,y] of Object.entries(data)){
		if(typeof y == "object" &&Array.isArray(y)==false){
			str=str+"<ul>"+refun(y)+"</ul>";
		}
		else{
			str = str+"<li>"+x+"  :  "+y+"</li>";
		}
	}
	return str+"</ul>";
}
</script>
</html>