title: Autosave HandsOnTable data to JSON
body: <p>I'm working with HandsOnTable and trying to implement saving to a JSON file on the server.</p>
  
  <p>This is how the page looks like:</p>
  
  <pre><code>&lt;div id="example1" class="handsontable"&gt;&lt;/div&gt;
  &lt;button name="save"&gt;Guardar&lt;/button&gt;
  </code></pre>
  
  <p>And the jQuery:</p>
  
  <pre><code>var handsontable = $container.data('handsontable');
  
  $parent.find('button[name=save]').click(function () {
    $.ajax({
      url: "save.json",
      data: {"data": handsontable.getData()}, //returns all cells' data
      dataType: 'json',
      type: 'POST',
      success: function (res) {
        if (res.result === 'ok') {
          $console.text('Data saved!');
        }
        else {
          $console.text('Save error');
        }
      },
      error: function () {
        $console.text('Save error.');
      }
    });
  });
  </code></pre>
  
  <p>I'm also working on a PHP script to write all cells' data above to a JSON file, it should be called whenever the user clicks the save button. This how it looks now:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['save'])){
  
      $myFile = "testFile.json";
      $fh = fopen($myFile, 'w') or die("can't open file");
      $stringData = "Floppy Jalopy\n";
      fwrite($fh, $stringData);
      fclose($fh);
  };
  
  ?&gt;
  </code></pre>
  
  <p>My question is how do I send all the cell's data to the PHP variable $stringData?</p>
  
  <p>Thanks a lot in advance!</p>