Sierra Trading Post: API Brands Demo

by Adam Patridge

HTML

<ul class="results">
</ul>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type="text/javascript" src="http://jquery-jsonp.googlecode.com/files/jquery.jsonp-2.1.4.min.js"></script>

JavaScript

$(function () {
    var apiKey = "xe5s5rpag9y4ear9bwxsu48e",
    // Use your own API key. This is a demo API key and is heavily throttled.
        $results = $(".results");
    $.jsonp({
        url: "http://api.sierratradingpost.com/api/1.0/brands/?api_key=" + apiKey,
        callbackParameter: "callback",
        success: function(data) {
            var brandIndex,
                brand,
                brandListItem,
                brandLink;
            for (brandIndex in data.Result) {
                brand = data.Result[brandIndex];
                brandListItem = $("<li>");
                brandListItem.text(brand.Name);
                brandListItem.appendTo($results);
            }
        }
    });
});