title: ASP MVC3 - Make second call to controller once jQuery autocomplete value selected
body: <p>Below are the jQuery versions that I am referencing in my ASP MVC view</p>
  
  <pre><code>&lt;script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Using the <code>autocomplete</code> widget, I would like the form to fill out a separate text box based on the user's selection from the <code>autocomplete</code> list. On this page, the user will begin typing a bank name. Once the user selects which bank they need, another field by the name of <code>Dynamics ID</code> needs to be populated with the appropriate value. Here is the jQuery as it's written right now</p>
  
  <pre><code>$(function () {
      $("#BankNameAuto").autocomplete({
          source: '@Url.Action("GetBanks", "AgentTransmission")',
          minLength: 1,
          onComplete: function (data) {
              $.getJSON('@Url.Action("GetDynamicsId", "AgentTransmission")', data, function (result) {
                  $('Dynamics').val(result);
              })
          }
      });
  });
  </code></pre>
  
  <p>And here are the two controller methods that are called in the above jQuery</p>
  
  <pre><code>    //GET
      public JsonResult GetBanks(string term)
      {
          var banks = from c in db.BankListMaster.Where(n =&gt; n.BankName.Contains(term))
                          select c.BankName;
  
          banks = banks.Distinct();
  
          return Json(banks, JsonRequestBehavior.AllowGet);
      }
  
      //GET
      public JsonResult GetDynamicsId(string term)
      {
          var dynamics = from c in db.BankListMaster.Where(n =&gt; n.BankName.Equals(term))
                      select c.LinkRepsToDynamicsUniqueId;
  
          dynamics = dynamics.Distinct();
  
          return Json(dynamics, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p><strike>Once the user has made a selection from the list, I wanted to be able to send back the <code>ID</code> value to that bank. That serves as the primary key for the <code>BankListMaster</code> table, of which <code>BankName</code> and <code>DynamicsId</code> are both fields. I'm still new to jQuery, however, so I may not be able to do this.</strike> </p>
  
  <p>Right now, I've set a breakpoint in the first line of both controller methods. The <code>GetBanks</code> breakpoint fires everytime, however I cannot get the <code>GetDynamicsId</code> to fire at all. </p>
  
  <p>EDIT </p>
  
  <p>Since I'm only selecting the <code>BankName</code> field in the first query, I adjusted the <code>GetDynamicsId</code> method to use the bank name as the parameter. </p>