Skip to content

Instantly share code, notes, and snippets.

@stevenfollis
Last active January 4, 2016 08:49
Show Gist options
  • Save stevenfollis/8597630 to your computer and use it in GitHub Desktop.
Save stevenfollis/8597630 to your computer and use it in GitHub Desktop.
SharePoint 2010 REST Endpoint Operations using jQuery
//==================================================================
// 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