Add listitem with javascript
2015-07-16 20:23
656 查看
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', createListItem);//makes sure sp.js is loaded and then calls createListItem method function createListItem() { 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('ListName'); var itemCreateInfo = new SP.ListItemCreationInformation(); this.oListItem = oList.addItem(itemCreateInfo); oListItem.set_item('Title', 'My New Item!'); oListItem.set_item('Body', 'Hello World!'); oListItem.update(); clientContext.load(oListItem); 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()); }
shareimprove this an |
相关文章推荐
- Add listitem with javascript 分类: Sharepoint 2015-07-16 20:23 4人阅读 评论(0) 收藏
- 【JavaScript 11—应用总结】:下拉菜单
- 【JavaScript 11—应用总结】:下拉菜单
- JS模块化编程——seajs
- 使用js和AJAX实现的异步请求
- javascript之Dorm
- 【JavaScript】——基础(一)
- js中Dom对象的position属性
- Javascript之第三方程序库
- 初步探索fastJson
- 在mvc返回JSON时出错:序列化类型为“System.Data.Entity.DynamicProxies.Photos....这个会的对象时检测到循环引用 的解决办法
- javascript(一)
- $.toJSON的使用方法
- [JSOI2007][BZOJ1029] 建筑抢修
- Maven Missing Artifact 问题(ezmorph, json-lib)
- jackson json 序列化与反序列化时json中字段名称问题
- JSON.parse()与JSON.stringify() (浏览器兼容性:IE8以上、Chrome、Firefox3.5、Opera10.5、Safari4.0)
- Js 对象添加属性
- js json string 互转
- js的一种闭包用法