title: Get list at site collection level using SP.js
body: <p>I have this code which is meant to get data from a list at the site collection level.</p>
  
  <pre><code>var clientContext = new SP.ClientContext.get_current();
  
      var oList = clientContext.get_site().openWeb().get_lists().getByTitle('ListName');
      var query = "query here";
  
      var camlQuery = new SP.CamlQuery();
      camlQuery.set_viewXml(query);
      collListItem = oList.getItems(camlQuery);
  
      clientContext.load(collListItem);
  
      clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
  </code></pre>
  
  <p>I had modified the lines below which gets data from the current web </p>
  
  <pre><code>var clientContext = new SP.ClientContext.get_current();
  
  
      var oList = clientContext.get_web().get_lists().getByTitle('ListName');
  </code></pre>
  
  <p>to this</p>
  
  <pre><code>var clientContext = new SP.ClientContext.get_current();
  
      var oList = clientContext.get_site().openWeb().get_lists().getByTitle('ListName');
  </code></pre>
  
  <p>Usually you open the site then the web and then get to the list but it doesn't seem to work in JS.</p>
  
  <p>Can you please point out what I need to do fix it?</p>
  
  <p>Thanks,</p>