title: Create html from json fetched with ajax
body: <p><strong>What I want to do:</strong></p>
  
  <p>I have an application based on symfony2 (php). A simple action returns data as json like this</p>
  
  <pre><code>    $headers = array(
          'Content-Type' =&gt; 'application/json'
      );
  
      return new Response($data, 200, $headers);
  </code></pre>
  
  <p>This action is called from javascript like this</p>
  
  <pre><code>function loadData(action){
      $.ajax({
          type: "POST",
          url: action,
          success: function(data){
              console.log(data);
          },
          error: function(XMLHttpRequest, textStatus, errorThrown) {
              alert(errorThrown);
          }
      });
  }
  </code></pre>
  
  <p>So this seems very basic so far. From the console I can see the correct data returned. This data should be  placed somewhere on the project website.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>Is there any straight forward way to create html from json within javascript? Actually I want seperate templates (twig) from the logic of the project. So would it be correct to generate the html e.g. in the success callback in the loadData method?</p>
  
  <p>I could bypass this problem by returning html instead of json. But I think about building some kind of rest api for my project which I think required json for transport.</p>
  
  <p>Any suggestions or ideas? Please share your ways of handling this.</p>