I want to use the updatelist ot updatelistitem function from here. I want to add a counter to the page. And i want to increase it with code. I thought this way would useful for me. I did not find any sample. How can i do that?
1 Answer
Why not use JSOM to update the list in your code on your page. It is going to use list.asmx to perform the update. To update your list using JSOM, it should be as simple as this below:
function updateListItem(itemId) {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('My List');
this.oListItem = oList.getItemById(itemId);
oListItem.set_item('MyField', 'My Updated Field Value');
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
alert('Item updated!');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
Put it in a $(document).ready(function(){});
and there you go. There is no need to invoke the _vti_bin directly.