title: How to dynamically update jquery datatable using js array as data source
body: <p>How to dynamically update jquery datatable using js array as data source.
  When user click the update button a new js array should be added current data source and it should reflect on jquery datatable.   </p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;       
          &lt;link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.6/css/jquery.dataTables.css"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="demo"&gt;&lt;/div&gt;
          &lt;button id="update"&gt;Update&lt;/button&gt;  
  
      &lt;script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="//cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
      var dataSet = [
          ['Trident','Internet Explorer 4.0','Win 95+','4','X'],
          ['Trident','Internet Explorer 5.0','Win 95+','5','C'],
          ['Trident','Internet Explorer 5.5','Win 95+','5.5','A'],    
      ];
  
      var ctr = 0;
      $("#update").click(function() {        
          ctr++;
          dataSet.push([ctr,ctr,ctr,ctr,ctr]);
          console.log(JSON.stringify(dataSet));
      });
  
  $(document).ready(function() {
      $('#demo').html( '&lt;table cellpadding="0" cellspacing="0" border="0" class="display" id="example"&gt;&lt;/table&gt;' );
       $('#example').dataTable( {
          "data": dataSet,
          "columns": [
              { "title": "Engine" },
              { "title": "Browser" },
              { "title": "Platform" },
              { "title": "Version", "class": "center" },
              { "title": "Grade", "class": "center" }
          ]
      });   
  });
  
      &lt;/script&gt;        
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>