Skip to content

Instantly share code, notes, and snippets.

@stevekinney
Created October 14, 2015 18:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevekinney/27d78c77de4fdbf8726c to your computer and use it in GitHub Desktop.
Save stevekinney/27d78c77de4fdbf8726c to your computer and use it in GitHub Desktop.
var person = {
firstName: 'Steve',
lastName: 'Kinney',
updateName: function () {
$.getJson('/api/vi/person', function () {
this.firstName = 'Wes'
}.bind(this));
}
};
$.ajax({
method: 'GET',
dataType: 'application/json',
url: '/api/v1/whatevers',
success: function (data) {
console.log(data);
},
failure: function () {
alert('I failed miserably.');
}
})
$.getJson('api/vi/whatevers', (data) => {
console.log('Success!')
}, (errorMessage) => {
alert('FAIL!!!!')
});
$.getJson('api/vi/whatevers')
.then(function (idea) {
addIdeaToThePage(idea)
})
.fail(function (errorMessage) {
alert(errorMessage);
});
$.post('/api/v1/whatevers', { title: 'My Inspiration', body: 'wowowowow'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment