<script id="template" type="text/x-jquery-tmpl"> <tr> <td><a href="http://p2pu.org${path}">http://p2pu.org${path.substr(0,60)} ...</a></td> <td>${visitors}</td> </tr> </script> <div id="mydiv"> <table> <thead> <tr> <th>Page</th> <th>Visits</th> </tr> </thead> <tbody id="info"></tbody> </table> </div>
var apikey="85d9048958caa51a01d1b8bc568fd6d2"; var host="p2pu.org"; var url = "http://api.chartbeat.com/quickstats"; url += "?host=" + host; url += "&apikey=" + apikey; url += "&jsonp=?"; $.getJSON(url,function(data) { $("#template").tmpl(data.toppages).appendTo("#info"); });
table { border-collapse: collapse; border: 1px solid #666666; } table td, table th { padding: 5px; border: 1px solid #666666; }