title: SharePoint List items with the same titles using ECMAScript
body: <p>What i need is to add  a script to Visual Web Part  witch would display ListItems with same titles in textbox by clicking button. 
  As a foundation i used this script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  ExecuteOrDelayUntilScriptLoaded(MainFunction, "sp.js");
  
  var objContext = null;
  var objWeb = null    
  var objList = null;
  var objItem = null;
  
      function MainFunction() {  
          objContext = new SP.ClientContext.get_current();
          objWeb = objContext.get_web();  
          objList = objWeb.get_lists().getByTitle("Product");
  
          objContext.load(objList);
  
          objContext.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));  
      }  
  
      function onSuccess(sender, args) {
          alert('Item Count: ' + objList.get_itemCount());
      }  
  
      function onFail(sender, args) {  
          alert('Some error has occured.');  
      } 
   &lt;/script&gt;
  </code></pre>
  
  <p>My question is: "Is there a way to somehow improve this script to accomplish my goal?"</p>