title: Handle session timeout when loading data through ajax with jquery DataTables
body: <p>My application is behind a sign in, so when loading the data through ajax, I need to verify the user still has an active session.  If the user does not have an active session, I return back with <code>echo json_encode(array('TIMEOUT'));</code> which outputs <code>["TIMEOUT"]</code>.  How do I read that response and send the user back to the sign in page?</p>
  
  <p>In previous versions of DataTables, I was able to do the following:</p>
  
  <pre><code>"fnServerData": function ( sSource, aoData, fnCallback, result ) {
                              $.getJSON( sSource, aoData, function (json) { 
                                if(json == "TIMEOUT")
                                {
                                  window.top.location.href = "/sign_out?action=to";
                                  return;
                                }
  
                                fnCallback(json)
                              } );
  </code></pre>
  
  <p>Under DataTables 1.10, <code>fnServerData</code> has been replaced by <code>ajax</code> (see <a href="https://datatables.net/upgrade/1.10-convert" rel="nofollow">docs</a> and <a href="https://datatables.net/reference/option/ajax.data" rel="nofollow">ajax.data</a>).  How do I accomplish the same thing with the new DataTables version?  I feel like I am close, but it just isn't working...possible because I am doing something wrong attempting to parse the response (I never hit inside the if statement).</p>
  
  <pre><code>"ajax": {
          "url": "/account/location_load",
          "data": function (myJson) { 
              if(myJson == "TIMEOUT")
              {
                window.top.location.href = "/sign_out?action=to";
                return;
              }
  
              return myJson;
            }
        }
  </code></pre>