Skip to content

Instantly share code, notes, and snippets.

@j127
Last active December 26, 2015 22:29
Show Gist options
  • Save j127/7223255 to your computer and use it in GitHub Desktop.
Save j127/7223255 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
console.log('Document ready');
fetchEmployeeData();
function fetchEmployeeData() {
console.log('Running fetchEmployeeData()');
// Get JSON
$.ajax({
type: 'GET',
url: 'http://localhost:8888/data/employees.json',
dataType: 'json',
error: function(xhr, status, error) {
alert(xhr.responseText);
},
success: displayEmployeeData
});
}
function displayEmployeeData(data) {
console.log('Running displayEmployeeData()');
console.log('The data is:');
console.log(data);
var template = $('#employees-template').html();
var html = Mustache.render(template, data);
$('#employees-div').html(html);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment