title: Jquery Datatables Ajax Response
body: <p>I am trying to follow the datatable example for Ajax data source (objects) found <a href="https://datatables.net/examples/ajax/objects.html" rel="nofollow">here</a>. I am using asp.net and have the following handler which receives my data, processes it and provides the response.</p>
  
  <pre><code>public class UsersHandler : IHttpHandler
  {
      private const string JsHeader = @"{{""data"" {0}}}";
  
  
      public void ProcessRequest(HttpContext context)
      {
          IEnumerable&lt;SystemUser&gt; data = SystemUserLogic.LoadAllSystemUsers();
  
          List&lt;SimpleUser&gt; userlist = new List&lt;SimpleUser&gt;();
          foreach (SystemUser su in data)
          {
              SimpleUser simple = new SimpleUser();
              simple.Id = su.Id;
              simple.FullName = su.NameFirst;
              simple.Email = "example@email.co.uk";
              userlist.Add(simple);
          }
          string json = JsonConvert.SerializeObject(userlist, Formatting.Indented);
          context.Response.ContentType = "text/plain";
          context.Response.ContentEncoding = Encoding.UTF8;
          context.Response.Cache.SetNoStore();
          context.Response.Expires = -1;
          context.Response.Write(String.Format(JsHeader, json));
      }
  </code></pre>
  
  <p>which deliveries the correct response when I catch it in the browser and look at the data via the network traffic. My aspx page contains the following.</p>
  
  <pre><code>$('#table_id').DataTable({
              "ajax": '/Handlers_New/UsersHandler.ashx',
              "columns": [
                  { "data": "Id" },
                  { "data": "FullName" },
                  { "data": "Email" },
                  { "data": "KeyResource" }
              ]
  
          });
  </code></pre>
  
  <p>However when the page loads, I am getting this error:</p>
  
  <p>DataTables warning: table id=table_id - Invalid JSON response. For more information about this error, please see <a href="http://datatables.net/tn/1" rel="nofollow">http://datatables.net/tn/1</a></p>
  
  <p>The outputted data looks like this, </p>
  
  <pre><code>    {"data" [
  {
  "Id": 1,
  "FullName": "Admin",
  "Email": "example@email.co.uk",
  "KeyResource": false
  },
  {
  "Id": 2,
  "FullName": "Jon",
  "Email": "example@email.co.uk",
  "KeyResource": false
  },
  {
  "Id": 3,
  "FullName": "Stephen",
  "Email": "example@email.co.uk",
  "KeyResource": false
  }, etc.....
  </code></pre>
  
  <p>Please tell me why I am getting this error. Should I be manipulating the json object differently, or am I missing something with the Jquery datatables? </p>