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
<html> | |
<script src="/SiteAssets/js/jquery.min.js"></script> | |
<script type="text/ecmascript"> | |
function Savedata() | |
{ | |
var clientContext = new SP.ClientContext.get_current(); | |
var oList = clientContext.get_web().get_lists().getByTitle('MyList'); | |
var itemCreateInfo = new SP.ListItemCreationInformation(); | |
this.oListItem = oList.addItem(itemCreateInfo); | |
oListItem.set_item('Column1', 'Welcome'); | |
oListItem.set_item('Column2', 'hi'); | |
oListItem.update(); | |
clientContext.load(oListItem); | |
//alert('Loaded'); | |
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); | |
} | |
function onQuerySucceeded() { | |
alert('Item created: ' + oListItem.get_id()); | |
} | |
function onQueryFailed(sender, args) { | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
} | |
</script> | |
<body> | |
<input type="button" Value="Save" onClick="Savedata()"/> | |
</body> | |
</html> |