title: MVC jquery calling a controller method not working
body: <p>I want to populate one drop down list based on the selection of another drop down list.</p>
  
  <p>I know it's a fairly common problem, and for two whole days I've been trying different samples that I find on the net, to no avail!</p>
  
  <p>Here is my code: </p>
  
  <p>controller: </p>
  
  <pre><code> public List&lt;SelectListItem&gt; listTestCases(string id)
      {
          IQueryable&lt;SelectListItem&gt; A = repository.listTestCases(id);
          return (A.toList());
      }
  
      public JsonResult listTestCases_2(string id)
      {
          IQueryable&lt;SelectListItem&gt; A = repository.listTestCases(id);
          return Json(A);
      }
  </code></pre>
  
  <p>I have two methods, one of them returns a List, the other one JSONResults, and I tried everything I found on the net with both methods.
  script:</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function() {
      $('select#testCategoriesUniqueId').change(function() {
  
          var testCategory = $(this).val();
          $.ajaxSetup({ cache: false });
          alert(testCategory);
  
          $.getJSON("TestInput/listTestCases/" ,  {id: testCategory}, function(data) {
              alert("here");
          });
  
      });
  });
  </code></pre>
  
  <p></p>
  
  <p>With the above code, the code goes through the listTestCases, and get's the results, but It doesn't go to the success function. (doesn't alert)</p>
  
  <p>I have tried:</p>
  
  <pre><code> $.getJSON("TestInput/listTestCases/" + testCategory, null, function(data) {
              alert("here");
          });
  </code></pre>
  
  <p>not surprisingly same results.</p>
  
  <p>I even tried : (json-p)</p>
  
  <pre><code> $.ajax({
              url: "TestInput/listTestCases/" + testCategory,
              dataType: "json-p",
              success: function(data) {
                  alert(data.length);
                  var S = "";
                  $("#testCasesUniqueId").removeOption(/./);
                  for (var i = 0; i &lt; data.length; i++) {
                      S += data[i];
                      var val = data[i].Value;
                      var text = data[i].Text;
                      $("#testCasesUniqueId").addOption(val, text, false);
                  }
                  alert(S);
              }
          }
          );
  </code></pre>
  
  <p>and the result is a string (System.collections.List[...SelectListItem]. and does not give me the objects of the list. so I tried it with listTestCases2, and it is not even calling the method.</p>
  
  <p>I read somewhere that I need to use post instead of get, and I even tried postJSON. and no result.</p>
  
  <p>Basically I'm super lost.</p>