Question

My site has a search function that uses AJAX to complete the search. A POST request is sent to a PHP page and a results DIV is reloaded using the HTML returned.

I'd like to implement Chrome's tab to search feature using OpenSearch XML. I've been following the answer given at How to add google chrome omnibox-search support for your site?. The answer shows an example of how to implement the tab to search function using a GET request where the search is executed on a separate page.

How would I implement the tab to search function on a search engine that uses AJAX POST?

Was it helpful?

Solution

I ended up pushing a GET request to my index(search) page.

$search = $_GET["search"];

If a GET variable is supplied then the POST search is automatically performed

$(document).ready(function(){
    var $search = "<?php echo $search; ?>";
    if(search != "" && search != null){
        $.post("search.php", {search: search},
            function(data){
            $("#returneddiv").html(data);
        });
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top