Skip to content

Instantly share code, notes, and snippets.

@jonatasemidio
Created May 12, 2017 22:35
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 jonatasemidio/8633fca4584c36fcddcf1a1d636bb822 to your computer and use it in GitHub Desktop.
Save jonatasemidio/8633fca4584c36fcddcf1a1d636bb822 to your computer and use it in GitHub Desktop.
get file from github via ajax and github api [não está pronto]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<title>Get File From Github</title>
</head>
<body>
<script type="text/javascript">
$( document ).ready(function() {
// Handler for .ready() called.
alert("oi");
var response = '';
$.ajax({ type: "GET",
url: "https://raw.githubusercontent.com/github/gitignore/master/Actionscript.gitignore",
async: false,
success : function(text)
{
response = text;
}
});
alert(response);
$.ajax({
url:"https://api.github.com/repos/github/gitignore/contents/",
dataType:"jsonp",
success: function(results){
console.log(results)
}
});
alert("fim");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment