Thread: JSON problem
View Single Post
Old 03-06-2013, 01:11 PM   PM User | #3
wingsgb
New to the CF scene

 
Join Date: Jul 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
wingsgb is an unknown quantity at this point
tanks for your reply,

i still cant communicate with the JSON url data, all the guides i find is of when the JSON is stored locally in a file or the "var data" i also cant find any guides on how to communicate with with the code you gave me.

Iv never heard or used mustache/ handlebars before, so iv just had a read through there sites and come up with the below but didn't know what to do with the code you give me.

Code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/scripts/jquery-1.9.1.min.js" ></script>
<script type="text/javascript" src="/scripts/handlebars.js" ></script>
<script type="text/javascript" src="/scripts/mustache.js" ></script>


<script src="https://census.soe.com/get/ps2-beta/outfit/?name=Immortal%20Serial%20Killers&callback=console.log"> 
    $.getJSON('callback=console.log', function(data) {
    var template = $('#personTpl').html();
    var html = Mustache.to_html(template, data);
    $('#sampleArea').html(html);
});
</script>
</head>
<body>
<script id="personTpl" type="text/template">
<h1> {{id}} <br>  
{{name}} <br>
{{alias}} <br>
{{time_created}} <br>
{{leader_character_id}} </h1>
</script>
</body>
</html>
I'm probably going to use Google's chart API, that way i can display the data into tables and charts easily once i can establish the connection.

Last edited by wingsgb; 03-06-2013 at 01:50 PM..
wingsgb is offline   Reply With Quote