Create List Item Using Rest API
function UploadItemToList()
{
var Emp = $("#txtname").val();
$.ajax
({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Employee')/items",
type: "POST",
data: JSON.stringify
({
__metadata:
{
type: "SP.Data.EmployeeListItem"
},
Title: Emp
}),
headers:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "POST"
},
success: function(data, status, xhr)
{
},
error: function(xhr, status, error)
{
}
});
}
No comments:
Post a Comment