Created
March 22, 2014 08:51
-
-
Save vgrem/9703400 to your computer and use it in GitHub Desktop.
Read operation in SharePoint 2010 REST
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
function getListItemById(webUrl,listName, itemId, success, failure) { | |
var url = webUrl + "/_vti_bin/listdata.svc/" + listName + "(" + itemId + ")"; | |
$.ajax({ | |
url: url, | |
method: "GET", | |
headers: { "Accept": "application/json; odata=verbose" }, | |
success: function (data) { | |
success(data.d); | |
}, | |
error: function (data) { | |
failure(data.responseJSON.error); | |
} | |
}); | |
} | |
//Usage | |
getListItemById('https://contoso.sharepoint.com/project/','Tasks',2,function(taskItem){ | |
console.log(taskItem.TaskName); | |
}, | |
function(error){ | |
console.log(JSON.stringify(error)); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How using this code all items, here ony 1..((