How can I write out statuses from a json API? -
im trying server statuses written out on page on site using steam gauge api (http://steamgaug.es/docs). preferably want write out if isteamclient, isteamfriends, isteamuser , ieconitems_440 servers online or down.
i've never done before have no idea do.
help appreciated.
if understand correctly want same on http://steamgaug.es/ page. may go page, , view source of page , see example how such calls. (js not minified , located directly on html page) statuses, see use associated array , values hardcoded.
code clear:
var steamservices = { // actual statuses translation: { 0 : "<span style='color:#16a085'>online</span>", 1 : "<span style='color:#c0392b'>down</span>", 2 : "<span style='color:#c0392b'>500 internal server error</span>", 3 : "<span style='color:#c0392b'>empty response</span>", 4 : "<span style='color:#c0392b'>404 not found</span>", 5 : "<span style='color:#c0392b'>timeout</span>", 6 : "<span style='color:#c0392b'>unknown error</span>" }, // checking docheck: function(){ // show loading message $(".load-overlay").show(); // load data api $.ajax({ url: "http://steamgaug.es/api", type: "get", datatype: "json" }).done(function(data){ // populate fields $.each(data,function(i,v){ $("#"+i).html(steamservices.translation[v]); }); // hide loading message $(".load-overlay").hide(); }).fail(function( jqxhr, textstatus ) { // when there's error getting data if(jqxhr.status == 502){ $(".load-overlay").html("<i class=\"fa fa-exclamation-triangle\"></i><br/>service check error!<br/>try again soon."); $(".load-overlay").addclass("bad-load"); } }); } }
Comments
Post a Comment