EnjoySharePoint YouTube Channel

Add item to SharePoint list using JavaScript object model in SharePoint Online

In this post we will discuss how we can add an item to list using JavaScript object model. We also use jQuery here. You can use the code inside a script editor web part to make it work.

Get Office 365 Enterprise E3 Or Business Premium Subscription & Try out all the features

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”></script>

<input id=”txtTitle” name=”txtTitle” type=”text” />

<input name=”ADD” id=”btnAdd” type=”submit” value=”Add Item to List” />

<script language=”javascript” type=”text/javascript”>

$(document).ready(function () {

$(“#btnAdd”).click(function () {
var title = $(“#txtTitle”).val();
function AddListItem(TitleField) {
var ListName = “Employee”;
var context = new SP.ClientContext.get_current();
var lstObject = context.get_web().get_lists().getByTitle(ListName);
var listItemCreationInfo = new SP.ListItemCreationInformation();
var newItem = lstObject.addItem(listItemCreationInfo);
newItem.set_item(‘Title’, TitleField);
context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
Function.createDelegate(this, this.onFailure));
function onSuccess() {
alert(‘Item created’);
function onFailure(sender, args) {
alert(‘Request failed. ‘ + args.get_message() + ‘\n’ + args.get_stackTrace());

Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →