title: How to append table correctly in jquery?
body: <p>I am coming to an issue where I am appending to my table using jQuery and also to <code>&lt;div class=&quot;jobEntity&quot; id=&quot;bestTable&quot;&gt;</code>. For some reason I don't want to append my table like that. Is there a way to work around with my jQuery code to append the table properly? Thanks for the help.</p>
  <h1>{request.contextPath} - is just localhost:8080/</h1>
  <pre class="lang-js prettyprint-override"><code>var cache = {};
  
  $(&quot;#searchTextField&quot;).autocomplete({
    minLength: 2,
    focus: function(event, ui) {
      event.preventDefault();
    },
    source: function(request, response) {
      var term = request.term;
      if (request.term in cache) {
        response(cache[request.term]);
        return;
      }
  
      $.ajax({
        url: &quot;#{request.contextPath}/JobSearchItem.xhtml&quot;,
        type: &quot;GET&quot;,
        data: {
          term: request.term
        },
        dataType: &quot;json&quot;,
        success: function(data) {
          response(data);
        }
      });
    },
    select: function select(event, ui) {
      event.preventDefault();
      var url = '#{request.contextPath}/index.xhtml';
      var searchValue = ui.item.value;
      var data = new FormData();
      data.append('searchValue', searchValue);
      $.ajax({
        url: url,
        data: data,
        method: &quot;POST&quot;,
        processData: false,
        contentType: false,
        cache: false
      }).done(function(text) {
        $('#results').append($(text).find('#bestTable'));
        $('#results').append($(text).find('#textTable'));
        $('#results').append($(text).find('table'));
        $(&quot;#clearone&quot;).show();
      });
    },
    response: function response(event, ui, data) {
      if (!ui.content.length) {
        var message = {
          value: &quot;&quot;,
          label: &quot;NOTHING HAS BEEN FOUND&quot;
        };
        ui.content.push(message);
      }
    }
  });
  </code></pre>