Hi,
i have to add listitem to the list using JavaScript. But i am getting error in context Url.
var context = SP.ClientContext.get_current(); //gets the current context alert(context);-->alert showing objectobject not the site url var web = context.get_web(); //gets the web object alert(web);alert showing objectobject not the Weburl var list = web.get_lists(); //gets the collection of lists alert(list); function createItem() { // Retrieve the list and add an item to it. var targetList = list.getByTitle("VolunteerDocument"); alert(targetList); //create a new item object var listItemCreation = new SP.ListItemCreationInformation(); //add the item to the list using addItem method var newItem = targetList.addItem(listItemCreation); var listItemTitle = document.getElementById("txtCaption").value; alert(listItemTitle); var listItemCustom = document.getElementById("txtTitle").value; alert(listItemCustom); //using set_item method u can set the values to the item fields newItem.set_item('Description', listItemTitle); newItem.set_item('Title', listItemCustom); newItem.update(); context.load(newItem); context.executeQueryAsync(ItemCreationSuccess, ItemCreationFail); }
Can any one suggest me how to do this one..
Thanks...