PARSE JSON - EVAL - EACH - Dynamically Create UL OL From JSON

by bizamajig

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<div id='jsonresults'></div>

JavaScript

function AjaxSucceeded(result) {
        var items = [];

        $.each(eval(result), function (key, val) {
            items.push('<li id="product_' + key + '">' + val.Name + '</li>');
        });

        $('<ul/>', {
            'class': 'my-new-list',
            html: items.join('')
        }).appendTo('#jsonresults');

    }

AjaxSucceeded( '[{"Name":"Full Pallet","Price":"90.0000"},{"Name":"Half Pallet","Price":"60.0000"},{"Name":"Quarter Pallet","Price":"40.0000"},{"Name":"Small Parcel","Price":"30.0000"},{"Name":"Medium Parcel","Price":"20.0000"},{"Name":"Large Parcel","Price":"10.0000"}]' );