I have problem understanding arrays and loops, therefore this task is a bit confusing to me. Here\'s my stuff;
JSON
{
\"states\": [
I'm checked this script and this works properly:
var records = {
"states": [
{
"name": "johor",
"command": "view_johor"
},
{
"name": "selangor",
"command": "view_selangor"
},
{
"name": "melaka",
"command": "view_melaka"
},
{
"name": "kuala lumpur",
"command": "view_kl"
},
{
"name": "penang",
"command": "view_penang"
}
]
};
$.each(records.states, function (key, val) {
$('#ul').append($('- ').text('name: ' + val.name + ', command: ' + val.command));
});
and this is html: