/ Published in: JavaScript
                    
                                        
This code works for me without requiring any includes, plugins, or service packs. It should also integrate seamlessly with jquery.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(functionName, "sp.js"); //this is necessary to ensure the library is loaded before function triggered
function functionName() {
var clientContext = SP.ClientContext.get_current();
var myList = clientContext.get_web().get_lists().getByTitle('myList'); //actual list name here
var itemCreationInfo = new SP.ListItemCreationInformation();
var listItem = myList.addItem(itemCreationInfo);
listItem.set_item("Title", "the title"); //actual field names go in first argument, new assigned value in second
listItem.set_item("Field2", "tuna");
listItem.set_item("Field3", "ape");
listItem.set_item("Field4", "moose");
listItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this,this.Succeeded),Function.createDelegatethis,this.Failed));
}
function Succeeded() {
alert("Succeeded");
}
function Failed(sender,args) {
alert("fail");
}
</script>
Comments
 Subscribe to comments
                    Subscribe to comments
                
                