This is an extension of my previous question... it was resolved but a new issue has come up after getting past that.
Here's the code I'm currently using:
var clientContext = new SP.ClientContext("http://sitecollection/sites/Dev");
var oList = clientContext.get_web().get_lists().getByTitle('User List');
var item = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(item);
oListItem.set_item('Last Name', 'toby');
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
This fails on the callback (I think). See the below screenshot:
I am unsure where I am going wrong here... on my previous question, someome had mentioned using app context, something like this:
var context = new SP.ClientContext.get_current();
var hostContext = new SP.AppContextSite(context, hostUrl);
var hostWeb = hostContext.get_web();
But I can't call load
on hostWeb
... can anyone help me out here?