title: How to get data from Database/Model with JavaScript
body: <p>I'm new to ASP .NET, MVC and AngularJS so I'm trying to figure this all out still.</p>
  
  <p>I have a Model called <strong>Words.cs</strong> which contains:</p>
  
  <pre><code>namespace liveSearch.Models
  {
      public class Words
      {
          public int ID { get; set; }
          public string Word{ get; set; }
      }
  }
  </code></pre>
  
  <p>The database is already populated with data and I want to use JavaScript/JQuery to get every <strong>Word</strong> from the database so I can then manipulate that data in JavaScript etc.</p>
  
  <p>I currently have Razor in my <strong>index.cshtml</strong> which does:</p>
  
  <pre><code>@{
       foreach (var item in Model)
       {
           &lt;li&gt;
               @Html.DisplayFor(modelItem =&gt; item.Word)
           &lt;/li&gt;
       }
   }
  </code></pre>
  
  <p>This works in getting and displaying all Words in the model but I want to get rid of the Razor and use JavaScript/Jquery to get the data instead.</p>
  
  <p>Ideally, I want to get all Words from the DB (I don't care about the IDs) and add it to an array in the scope in the .js file. </p>
  
  <p>The problem is that I can't figure out how to access the DB with JavaScript or AJAX</p>
  
  <p>I think I can use <code>$.get()</code> or <code>$.ajax()</code> but I don't really know how to use it with a DB/model.</p>
  
  <p>I also read a few other posts here on Stackoverflow that said this can be done, but I wasn't able to apply any of those examples to my case for some reason.</p>