title: Capture If DataTable JSON/AJAX GET Populates Correctly Using 'Success/Error'
body: <p>I have a <code>DataTable</code> which is doing a <code>GET</code> but i was thinking that protection will be required to help improve UI and can display some sort of error so the user knows if the data is not displayed that an error has occurred and isn't sat watching a black screen.</p>
  
  <p>Any way i know how to do this in a <code>POST</code> but was wondering if there is a way of doing it in a <code>GET</code>.</p>
  
  <p><strong>Current 'Working code</strong></p>
  
  <pre><code>var existingRuleTable = $('#existingRulesDataTable').DataTable({
      "ordering": false,                                                  // Allows ordering
      "searching": false,                                                 // Searchbox
      "paging": true,                                                     // Pagination
      "info": false,                                                      // Shows 'Showing X of X' information
      "pagingType": 'simple_numbers',                                     // Shows Previous, page numbers &amp; next buttons only
      "pageLength": 10,                                                   // Defaults number of rows to display in table. If changing this value change the show/hide below
      "dom": '&lt;"top"f&gt;rt&lt;"bottom"lp&gt;&lt;"clear"&gt;',                           // Positions table elements
      "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],              // Sets up the amount of records to display
      "fnDrawCallback": function () {
          if ($('#dialPlanListTable').DataTable().rows().count() &lt; 11) {
              $("div[class='bottom']").hide();                            // Hides paginator &amp; dropdown if less than 11 records returned
          } else {
              $("div[class='bottom']").show();                            // Shows paginator &amp; dropdown if 11 or more records are returned
          }
      },
      'ajax': {
          "type": 'GET',
          "url": "js/dataTable.json",                                     
          "data": function (data) {
              return data;
          }
      },
      "columns": [                                                        // Display JSON data in table
          { "data": "position" },
          { "data": "startTime" },
          { "data": "endTime" },
          { "data": "selectedDays" },
          { "data": "selectedDates" },
          { "data": "selectedMonths" },
          { "data": "timeRange" },
          {
              "data": null,
              "render": function (data) {
                  if (buttonclicked == 'Modify') {                        // Displays the radio button when 'Mod' clicked
                      return  '&lt;label class="c-radio" style="margin-bottom: 0px"&gt;'
                          +   '&lt;input type="radio" name="existingRuleActionRadioButton" value="option1"&gt;'
                          +       '&lt;span class="fa fa-check"&gt;&lt;/span&gt;'
                          +   '&lt;/label&gt;';
                  } else if (buttonclicked == 'Delete') {                 // Displays the delete button when 'Del' clicked
                      return '&lt;button name="deleteRuleButton" class="btn btn-danger" id="' + data.position + '"&gt;'
                          + '&lt;i class="fa fa-trash-o" style="font-size: large"&gt;&lt;/i&gt;'
                          + '&lt;/button&gt;';
                  } else {
                      return ''; // Needed for the 'Add' button click
                  }
              }
          }
      ]
  });
  </code></pre>
  
  <p><strong>Things i have tried</strong>
  Added this at the end which works BUT i don't know the state (success/error)</p>
  
  <pre><code>"initComplete": function(settings, json) {
       alert( 'DataTables has finished its initialisation.' );
  }
  </code></pre>
  
  <p>Then tried the blow <code>AJAX</code> which fires and dropd into the correct 'Success/Error' but this then does not render my <code>DataTable</code></p>
  
  <pre><code>'ajax': {
      "type": 'GET',
      "url": "js/dataTable.json",
      "data": function (data) {
          return data;
      },
      success: function(data){
          alert('Success');
      },
      error: function(e){
          alert('Failed');
      }
  },
  </code></pre>