It sounds like there is a problem with the way the server responds to AJAX calls, and not a problem with the form or javascript. I would suggest that you need to debug a couple of key areas.
Ideally, you will debug this using Xdebug on your Apache connected to your IDE (Netbeans, Eclipse, etc.). My personal preferences / settings are Netbeans, but others will work fine. If you cannot use live debugging, you can embed print_r / echo instructions through code blocks and track the call this way.
- Mage_CatalogSearch_AjaxController
javascript on form.mini.phtml should send a request to Mage_CatalogSearch_AjaxController and suggestAction . Set breakpoints / trace messages on each side of the first if in this method.
If the breakpoint / trace does not fall, try to manually perform the action by placing http://hostname/catalogsearch/ajax/suggest?q=query in the address bar of the browser.
If this does not work, there is something broken with the configuration of the catalogsearch module, possibly with the section <frontname><routers> . Use the Alan Storm Configviewer or CommerceBug modules to debug them.
- Mage_CatalogSearch_Block_Autocomplete
AjaxController creates an instance of Mage_CatalogSearch_Block_Autocomplete that executes the actual request. Set a breakpoint / trace immediately before $suggestData = $this->getSuggestData(); to verify that the block is receiving an instance.
After this line, the block calls its own getSuggestData() method. Keep track of the code to see where the error occurred.
- Mage_CatalogSearch_Model_Query :: getSuggestCollection ()
The block calls this method to obtain values ββthat correspond to the q parameter, in particular, the setQueryFilter() method, which inserts this parameter into the SQL query criteria. Again, follow here to find the error.
I can't really emphasize how much easier it will be for you to find this (and most Magento issues) when you use live debugging in your IDE. Read my answer here if you need advice on this process.
Make sure you have a Developer Mode server to display as many errors as possible.
Jonathan day
source share