title: DataTables AJAX dynamic URL
body: <p>I want to create a general function to initialise all my ajax DataTables.</p>
  
  <p>I need to be able to identify the table that is requesting data so my server-side script knows which data to send back.</p>
  
  <p>I thought I'd simply be able to attach the table ID to the ajax URL like so:</p>
  
  <pre><code>$(document).ready(function() {
      $('#example').DataTable({
          "ajax": {
              "url": "www.example.com/load-" + this.id + ".php"
          }
      });
  });
  </code></pre>
  
  <p>I thought the URL would resolve to "www.example.com/load-example.php" but it didn't work as <code>this.id</code> is undefined (as is <code>$(this).attr('id')</code>) so I thought maybe I could use a single server-side script and pass in an extra $_GET parameter like so:</p>
  
  <pre><code>$(document).ready(function() {
      $('#example').DataTable({
          "ajax": {
              url: "www.example.com/load-table.php",
              data: function ( d ) {
                  d.experiment = this.id;
              }
          }
      });
  });
  </code></pre>
  
  <p>This also failed for the same reason.</p>
  
  <p>Is it possible to get the table ID when retrieving data this way?</p>