Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Last active August 5, 2017 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blairanderson/444e40f2475558ffdc9b94b3dfcdac3a to your computer and use it in GitHub Desktop.
Save blairanderson/444e40f2475558ffdc9b94b3dfcdac3a to your computer and use it in GitHub Desktop.
Fetching a GitHub Repo Readme with AJAX (example)
function success(data, status, xhr) {
$('#readme-content').html(data);
}
function error(data, status, xhr) {
$('#readme-content').remove();
}
$.ajax({
dataType: 'text',
url: 'https://api.github.com/repos/{{page.repo}}/readme',
headers: { Accept: 'application/vnd.github.v3.html' },
success: success,
error: error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment