Ajax request returns code instead of result of the query (solved) I'm trying to answer my own question in this post Basically, I have a bunch of checkboxes in multiple categories and when clicked, I want to use Ajax to filter the results and show them on the same screen.  I'm building up to that incrementally, and starting out by just trying to get the Ajax to work right with a single category filter.
My Ajax looks like this:
$('#filters input').change(function() {
  var value = $(this).val();

  $.ajax(&quot;ajax.twig?search=&quot; + value, {
    type: 'get',
    dataType: 'html',
    success : function(html) {
      $(&quot;#ajaxresults&quot;).html(html)
    },
    error: function(xhr, status, error) {
      alert(xhr.responseText);
    }
  });
});

ajax.twig look like this:
{% set searchTerm = craft.request.getParam('search') %}

{%  set galleries = craft.entries.section(&quot;gallery&quot;).colors(searchTerm) %}
{% if galleries|length %}

&lt;div class=&quot;gallery&quot;&gt;
  &lt;ul&gt;
    {% for gallery in galleries.all() %}
      &lt;li&gt;
        &lt;img src=&quot;{{ gallery.image[0].url }}&quot; alt=&quot;&quot; /&gt;
        &lt;h2&gt;{{ gallery.title }}&lt;/h2&gt;
      &lt;/li&gt;
    {% endfor %}
   &lt;/ul&gt;
 &lt;/div&gt;

{% endif %}

If I visit ajax.twig?color=red manually in the browser, it works as expected and I see the rendered result.  However, the page with the filters using ajax just returns the code inside ajax.twig rather than the result of the query.  I've also tried using .load() and .get() and had the same result.
Does anyone know what I'm doing wrong? I've been stuck for days. Thanks in advance.
The path to the ajax file was wrong. I had it as:
$.ajax(&quot;templates/ajax?search=&quot; + value, {

when it should have been
$.ajax(&quot;ajax?search=&quot; + value, {