Last active
August 29, 2015 13:56
-
-
Save rfaisal/9176840 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
var _url = 'http://localhost:49811/'; // the api root url | |
var _sample_greeting = 'Hey, there!'; // a sample greeting | |
//get all, sample JSON response: [{"id":1,"content":"Hey!"},{"id":2,"content":"Morning!"}] | |
$.ajax({type: "GET", url: _url + 'api/greetings', success: function (_d) {/*do stuff with _d*/}); | |
//create new | |
$.ajax({type: "POST", url: _url + 'api/greetings/', data: {'':_sample_greeting}}); | |
//update the 1st greeting | |
$.ajax({type: "PUT", url: _url + 'api/greetings/?id=1', data: {'':_sample_greeting}}); | |
//delete the 1st greeting | |
$.ajax({type: "DELETE", url: _url + 'api/greetings/?id=1'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment