Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Created February 18, 2013 19:10
Show Gist options
  • Save TiuTalk/4979804 to your computer and use it in GitHub Desktop.
Save TiuTalk/4979804 to your computer and use it in GitHub Desktop.
function getGitHubStats(callback, page, items) {
var page = page || 1,
items = items || [],
maxPage = 3;
$.ajax({
type: 'GET',
url: 'https://api.github.com/users/TiuTalk/events',
data: { page: page },
async: false,
cache: true,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function(json) {
if (json.meta.status !== 200) {
hideChart();
}
$.merge(items, json.data);
if (page < maxPage) {
getGitHubStats(callback, page + 1, items);
} else {
callback(processGitHubData(items));
}
},
error: hideChart
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment