title: Return List<T> from controller to ajax in asp.net mvc4
body: <p>I am trying to get a list from controller upon a jquery ajax call. </p>
  
  <p>But it returns an error 'Unexpected token S'.</p>
  
  <p>UPDATE- Controller code is Ok. It successfully preparing the list. But ajax shows this error.</p>
  
  <p>jquery ajax code-</p>
  
  <pre><code>var urlData = '@Url.Action("GetThanas", "AgentKycEntry")';
  $.ajax({
  type: "POST",
  url: urlData,
  contentType: "application/json; charset=utf-8",
  data: "{'id':'" + selectedVal + "'}",
  dataType: "json",
  success: function (result) {
  //tasks with restul
  },
  error: function (request, status, error) {
  alert("Request: " + request + " Status: " + status + " Error: " + error);
  }
  });
  </code></pre>
  
  <p>Code in controller</p>
  
  <pre><code>    [HttpPost]
      public List&lt;Thana&gt; GetThanas(int id)
      {
          return Thana.GetThanaList(id);
      }
  </code></pre>
  
  <p>UPDATE- Model code</p>
  
  <pre><code>   public class Thana
  {
  
      public String ThanaId { get; set; }
      public String ThanaName { get; set; }
  
      public Thana() { }
  
  
      public static List&lt;Thana&gt; GetThanaList(Int32 districtId)
      {
          List&lt;Thana&gt; thanaList = new List&lt;Thana&gt;();
  
  
          String ConnectionString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
          using (SqlConnection Connection = new SqlConnection(ConnectionString))
          {
              using (SqlCommand cmd = new SqlCommand("Select ThanaId,ThanaName From tblThanas where ThanaId&lt;&gt;0 And DistrictId=" + districtId + " or DistrictId=0 order By DisplayOrder ASC, ThanaName ASC ", Connection))
              {
                  Connection.Open();
                  SqlDataReader Reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                  while (Reader.Read())
                  {
                      Thana thana = new Thana();
                      thana.ThanaId = Reader["ThanaId"].ToString();
                      thana.ThanaName = Reader["ThanaName"].ToString();
                      thanaList.Add(thana);
                  }
                  if (!Reader.IsClosed)
                  {
                      Reader.Close();
                  }
              }
          }
  
  
  
          return thanaList;
      }
  
  }
  </code></pre>
  
  <p>Any suggestion ? </p>