Last active
June 3, 2016 16:43
-
-
Save twolfe2/8b4970b384083155ba03898bf559f21f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//when the button on the page is clicked the ajax request will be made | |
$('button').click(function(event){ | |
event.preventDefault(); //prevents browsers default behavior | |
//make the ajax request | |
$.ajax({ | |
url: https:'//api.github.com/users/twolfe2', //url could be first parameter to $.ajax instead | |
data: { | |
format: 'json'//tells github we want our data in json format | |
}, | |
error: function (){ | |
alert("An error occured"); | |
}, | |
dataType: 'jsonp',//JSONP allows us to make a cross-domain request | |
success: function(response) { | |
alert("GitHub User:" + response.login + "is located in" + response.location); | |
}, | |
type: 'GET' //GET is the default | |
}); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment