title: SharePoint Online Uncaught TypeError: Cannot read property 'apply' of undefined
body: <p>I'm trying to create a SharePoint list item when user clicks a button.
  I can't figure out how to fix the error I'm getting. The code still seems to work as intended however.</p>
  
  <p>HTML source:</p>
  
  <pre><code>&lt;button type="button" class="btn btn-info" id="getPollval"&gt;Submit&lt;/button&gt;'
  </code></pre>
  
  <p>Script - to get value from radio buttons:</p>
  
  <pre><code>var pName = '[name="Poll' + pollId + '"]:checked';
  var pId = 'Poll' + pollId;
  document.getElementById("getPollval").onclick = function() {
      var pollValue = document.querySelector(pName);
      createListItem(pollValue.value, pId , pollTitle);
  }
  </code></pre>
  
  <p>Script - to create list item on SharePoint:</p>
  
  <pre><code>var siteUrl = '/sites/MyList';
  
  function createListItem(pollValue, pId, pollTitle) {
  
      var clientContext = new SP.ClientContext(siteUrl);
      var oList = clientContext.get_web().get_lists().getByTitle('PollCustomResponses');
  
  var itemCreateInfo = new SP.ListItemCreationInformation();
  this.oListItem = oList.addItem(itemCreateInfo);
  
  oListItem.set_item('Title', pollTitle);
  oListItem.set_item('Response', pollValue);
  oListItem.set_item('PollID', pId);
  
  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());
  }       
  </code></pre>
  
  <p>When I click the <code>submit</code> button, it would create a new list item as intended. However, I'm getting below error message in DevTools:</p>
  
  <p><strong>Uncaught TypeError: Cannot read property 'apply' of undefined</strong></p>
  
  <p>The error is highlighting the <code>clientContext.executeQueryAsync</code> line when inspected.</p>