I'm using the code from this MSDN guide: http://msdn.microsoft.com/en-us/library/office/hh185011(v=office.14).aspx
Here's what it looks like:
var clientContext = new SP.ClientContext("http://sitecollection/sites/Dev");
var oList = clientContext.get_web().get_lists().getByTitle('User List');
var item = new SP.ListItemCreationInformation();
this.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));
The onQuerySucceeded and onQueryFailed methods exist and are just basic alerts... nothing fancy.
When I get to this line:
oListItem.set_item('Last Name', 'toby');
I get an error:
0x800a1391 - JavaScript runtime error: 'oListItem' is undefined
A couple questions:
What is
oListItemanyway? Why is it referred to asthis.oListItemthe first time, and just asoListItemsubsequently?How do I properly add an item to a list on my site? My list does exist and is under the URL
http://sitecollection/sites/Dev/Lists/User%20List/AllItems.aspx