Thread: JSON problem
View Single Post
Old 03-07-2013, 03:07 AM   PM User | #8
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
I used length because the object returns arrays, so that for loop is the way you can iterate through all the arrays members and access their indiviual information.

"info" is the id of the div where the results get rendered, same as "results" in your original code

your example will never work for a variety of reasons, and creating a table with innerHTML is almost impossible because of stupid IE. But if that's all you want to do, why not do something like this:
Code:
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="info"></div>

<script type="text/javascript">

function showIt(o) {

var outfits=o.outfit_list
for (var i = 0; i < outfits.length; i++) {
document.getElementById("info").innerHTML+="<span>alias: "+outfits[i].alias+"</span> "
+"<span>id: " +outfits[i].id+"</span><br>";
	}
	}	
</script>
<script src="https://census.soe.com/get/ps2-beta/outfit/?name=Immortal%20Serial%20Killers&c:resolve=member_character(name,type.faction,times,stats.facility_capture_count,stats.facility_defended_count,stats.kill_death_ratio,certs,experience,stats.kills.faction)&callback=showIt"></script>

</body>
</html>
xelawho is offline   Reply With Quote