var showUserList = function(){
$('#app').load('/html/users.html #userListDiv', function() {
$.getJSON('/users', function(data) {
// create the user list
var items = [ '
'];
$.each(data, function(index, item) {
items.push('- '
+ item.name + '
');
});
items.push('
');
var result = items.join('');
// clear current user list
$('#userListDiv').html('');
// add new user list
$(result).appendTo('#userListDiv');
});
}
};