title: How to Save and retrieve HTML 5 canvas (Fabric.js) into MySQL blob
body: <p>I want to save and retrieve HTML 5 canvas that I have drawn using Fabric.js, a JavaScript library, into MySQL table using PHP that has a field namely <code>cnvs_obj</code> of <code>BLOB</code> type. I have seen a lot of tuts and Q/A sessions but none has step by step way of teaching. How can I do this, would be very much thankful to you. Here is my canvas example.
  <strong>EDIT:</strong>
  Here is my complete code:</p>
  
  <pre><code>&lt;canvas id="c" style="border:1px solid black;" width="500px" height="300px" &gt;&lt;/canvas&gt;
  &lt;button onclick="myFunction()" id="btn2"&gt;Click me&lt;/button&gt;
  &lt;script type="text/javascript" src="fabric.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  var canvas = new fabric.Canvas('c');
  $(function () {     
      //canvas.stateful = true;
      var wel = new fabric.Text('Welcome to FabricJs', {
          fontFamily: 'Delicious_500',
          backgroundColor: 'red',
          left: 80, 
          top: 100 
      });
      canvas.add(wel);
  });
  canvas.renderAll();
  function myFunction() {
      console.log(JSON.stringify(canvas));
      var str_json = JSON.stringify(canvas);
      // send JSON to PHP
      $.ajax({
          type: 'POST',
          url: 'hallo_json.php',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8',
          data: { hallo_str: JSON.stringify(str_json) },
  
      });     
      alert(str_json);
  
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is PHP code:</p>
  
  <pre><code>&lt;?php
  header('Content-type: text/html');
  print_r(json_decode($_POST['str_json']));
  </code></pre>
  
  <p>Now I can generate JSON, but error 200 arises. I don't where is the error.</p>