title: Use Handlebars with Ajax and Jquery
body: <p>I am learning to use handlebars and I want to use it in an AJAX call, according to my idea, once I get the data from the server, I compile with Handlebars and then I print in a specific div but it throws me an error.
  Will my syntax be wrong?</p>
  
  <pre><code>&lt;div id="get_art"&gt;
  &lt;/div&gt;
  
  &lt;script id="artists-template" type="text/x-handlebars-template"&gt;
      &lt;ul class="artist"&gt;
      {{#each this}}
          &lt;li class="i"&gt;&lt;a class="i" href="{{url}}"&gt;&lt;img alt="{{name}}" src="{{image}}"&gt;&lt;span&gt; ""&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      {{/each}}
      &lt;/ul&gt;
  &lt;/script&gt;
  &lt;script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="&lt;?php echo $temporal . "/assets/js/main.js" ?&gt; "&gt;&lt;/script&gt;
  </code></pre>
  
  <p>It is my js:</p>
  
  <pre><code>jQuery(function($){
      $(document).ready(function() {
          $.ajax({
              type : 'POST',
              url  : 'http://localhost/test/api.php',
              data : 'endpoint=yahoo&amp;results=2&amp;wip=normal',
              dataType : 'json',
              beforeSend: function(){
                  $('#get_art').html('&lt;img src="'+baseUrl+'/assets/img/loading.svg" /&gt;');
              }
          }).done(function(data) {
              $('#get_art').html('');
              var artistsTemplateSource = document.getElementById('artists-template');
              var artistsTemplate = Handlebars.compile(artistsTemplateSource);
              var $artists = $('#get_art');
              $artists.html(artistsTemplate(data));
          });
      });
  });
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <pre><code>Error: You must pass a string or Handlebars AST to Handlebars.compile. You passed [object HTMLScriptElement]
  </code></pre>