SharePoint 2013 View/Delete List Item Via JavaScript and Rest

In Sharepoint 2013 you can use the Cliend-side OData service to contruct RESTful Http request against client.svc which internally calls out the Client Side Object Model API to pull/push data from the client to the server.

Read List item :

To read the List Tasks and by the Id of the item , the simple method can be used, where Tasks is the list name and 1 is the Id of the list item (internal Id)

http://34.231.97.77/_api/web/lists/getByTitle('Tasks')/getItemByStringId('1')

Delete List Item:

This runs against the client context and generates the url and passes it to the function to delete the item

removeItem = function (id) {
$.ajax(
{
url: _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getByTitle('Tasks')/
getItemByStringId('" +
The App Model ❘ 1
id + "')",
type: "DELETE",
headers: {
"accept": "application/json",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*"
},
success: function (data) {
readAll();
},error: function (err) {alert(JSON.stringify(err));}}
);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami