title: access denied for inserting item in sharepoint list by ECMA script
body: <p>Unable to insert item in sharepoint list by ECMA script with visitor privilege.<br/>
  I have added <code>&lt;sharepoint:FormDigest&gt;</code> control in master page of my site.<br/>
  I am able to run the code successfully by system account.<br/>
  <img src="https://i.stack.imgur.com/411bd.png" alt="enter image description here">
  Here is my code : <br/></p>
  
  <pre><code>try {
          var context = new SP.ClientContext.get_current(); 
          id = "123";
          var nameOnly = "ABC";
          var lstFavouritePosts = context.get_web().get_lists().getByTitle('DEF');
          var itemCreateInfo = new SP.ListItemCreationInformation();
          this.newListItem = lstFavouritePosts.addItem(itemCreateInfo);
          newListItem.set_item('Title', id);
          newListItem.set_item('User', nameOnly); 
          newListItem.update();
          context.load(newListItem);
          context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
          return false;
      }
  catch(msg)
          {
              alert(msg);
          }
  
  function onQuerySucceeded() {
              alert('ABC');
          return false;
      }
  function onQueryFailed(sender, args) {
      alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
      return false;
  }
  </code></pre>
  
  <p>Any suggestion will be appreciated.</p>