Simple AJAX search form So I've been following the docs on how to create a search form in Craft and it works fine. But instead of having a results.twig page I would like to have just one index page and get all the results with AJAX. Is there a simple way to accomplish this in Craft? And if so, does anyone have an example?
You can create your own search...
lets say this is your html

&lt;input type="input" id="searchTags" placeholder="Search"&gt;
&lt;input type="button" id="startSearch" value="Go"&gt;
&lt;div id="results"&gt;&lt;/div&gt;


then you have the following script:

$("#startSearch").click(function(){
    var data = {
        action: 'pluginhandle/controller/searchEntries',
        options: $("#searchTags").val()
    };
    $.ajax({
       type: "post",
       url: '/',
       data: data,
       success: function(response){
       // replace content from $("#results") with your new html
       },
    ....
   });
});


Your controller would look like

public function actionSearchEntry(){ 
     $criteria = new ElementCriteriaModel(ElementType::Entry);     
     // build your criteriaModel based on your needs
     $html = $this-&gt;renderTemplate('results.twig', array(
         'entries' =&gt; $criteria-&gt;find()
     ));
     return $this-&gt;returnJson($html);
}


your results.twig would be like

{% if entries is defined and entries|length %}
    &lt;ul&gt;
        {% for entry in entries %}
            &lt;li&gt;
                {{ entry.title }}
            &lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endif %}