Last active
January 4, 2016 08:49
-
-
Save stevenfollis/8597630 to your computer and use it in GitHub Desktop.
SharePoint 2010 REST Endpoint Operations using jQuery
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
//================================================================== | |
// Get list items | |
// define the target list url | |
var listUrl = 'http://samplesite/_vti_bin/ListData.svc/Employee'; | |
$.getJSON(listUrl, function(data) { | |
// loop through the result set | |
$.each(data.d.results, function(i, result) { | |
alert(result); | |
}); | |
}); | |
//================================================================== | |
//================================================================== | |
//TODO: Update | |
//================================================================== | |
//================================================================== | |
// Delete a list item | |
var id = 5; | |
var listUrl = 'http://www.contoso.com/_vti_bin/ListData.svc/'; | |
$.ajax({ | |
type: "DELETE", | |
url: listUrl + "(" + id + ")", | |
contentType: "application/atom+xml", | |
success: function (data, textStatus, jqXHR) { | |
alert('success'); | |
}, | |
error: function (xhr) { | |
alert(xhr.status + ': ' + xhr.statusText); | |
} | |
}); | |
//================================================================== | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment