I want to add list item through custom form using asynchronous javascript but i cant able to show any message on page that item created or not
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', createItem);//makes sure sp.js is loaded and then calls createListItem method
function createItem() {
var clientContext = new SP.ClientContext.get_current();//if the page and the list are in same site.If list is in different site then use relative url instead of get_current
var oList = clientContext.get_web().get_lists().getByTitle('Vendor');
var itemCreateInfo = new SP.ListItemCreationInformation();
oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item("Title", $('#RVendorDiv').val());
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(
Function.createDelegate(oListItem, oListItem.onQuerySucceeded),
Function.createDelegate(oListItem, oListItem.onQueryFailed)
);
}
function onQuerySucceeded() {
alert('Item created successfully ' );
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}