Ajaxsearch - adding Ajax search box into your blogs

Introducing Ajaxsearch, my first ajax (Asynchronous JavaScript and XML) attempt. With Ajaxsearch, you can add a search box into your blog that returns the search result to your users as they type.

For live example, please use the Seach box on the right panel.

Installation is easy,

1. Copy ajaxsearch.js and ajaxsearch.php into your blog directory.
2. Add the following codes into the area of your blog where you want the Ajaxsearch box to display

<script src="ajaxsearch.js"></script>
<form name="form1">
<input name="keyword" onKeyUp="SendQuery(this.value)" style="WIDTH:100px" autocomplete="off">
<div align="left" class="box" id="autocomplete" style="WIDTH:200px;BACKGROUND-COLOR:#EDF3DE"></div>
</form>
<script language="JavaScript"> HideDiv("autocomplete"); </script>

3. That’s it!

It currently supports Drupal and Wordpress blogs. It’s an opensource freeware. Feel free to try it and leave comments. I’m working to port it to other popular blog engines, or you may help to hack it.

Latest version: Download Ajaxsearch-0.1.

14 Responses to “Ajaxsearch - adding Ajax search box into your blogs”


  1. 1 ZEO

    ppl call this LiveSearch. there’s a plugin for wordpress and a wiki for it’s basic code.

  2. 2 blewtooth

    [quote=ZEO]ppl call this LiveSearch. there’s a plugin for wordpress and a wiki for it’s basic code.[/quote]
    Oops … look like I’ve just reinvented the wheel. Thanks for the link though.

  3. 3 cosa

    don’t worry, i prefer your script than the LiveSearch plugin. At least it’s easier to install than the plugin :p

    btw, i’ve modified your script a little bit. I changed the “name=keyword” to “name=s” and added “id=s”. Now if I press Enter on the Ajax search box, it will automatically use the build-in WP search.

  4. 4 blewtooth

    [quote=cosa]don’t worry, i prefer your script than the LiveSearch plugin. At least it’s easier to install than the plugin :p

    btw, i’ve modified your script a little bit. I changed the “name=keyword” to “name=s” and added “id=s”. Now if I press Enter on the Ajax search box, it will automatically use the build-in WP search.

    [/quote]
    Haha .. that’s something great to hear from you! :) BTW, if you happen to spot or fix any bug, pls let me know.

  5. 5 Dave

    I think you’ve got a much simpler/better implementation than LiveSearch. I wasted a ton of time yesterday trying to get that LiveSearch plugin working, with nothing to show for it. Then I did some Googling and found your site, and within 5 minutes I had a working search. Granted I had to do some tweaking to make it fit within my design, but I think you’ve got a great base here.

    You may have reinvented the wheel, but I think you’re using vulcanized rubber while the other guys have wood around their spokes.

  6. 6 B.Willey

    I have uploaded the files in the root directory of my blog, added the code, but when I do a search it responds with “Sorry, the search is not available.” What did I do wrong?

  7. 7 ky

    Try out ajax search engine http://askalexia.com, web, image, video searches available

  8. 8 Santo

    I also get the “Sorry, the search is not available.” message. It will search the site if I hit return, but the search is not live. Any clues as to why it’s not working?

    Thanks.

  9. 9 Nico

    I Made some modifications… take a look at http://nico.berlee.nl/instant-search-in-wordpress/ and blewtooth, you are welcome to put this in a 0.2 version… (the article was not ment as criticisme, but more, how to make your code more usefull…

  10. 10 mir

    I am trying to add this to my web site, is it possible to customize this search for mysql database instead of drupal or wordpress.

    what i want is when a user types something in the search box, the ajax search should query against the database table and bring back row ids.

    Thanks for the help anybody can provide.

  11. 11 Dan

    Mir - Take a look at my site, http://www.dormitem.com and check out the AJAX search feature in the middle of the page. It does exactly what you said, and queries against a mysql.

  12. 12 marc

    check out my site and try the search. as soon i start typing into the textbox this shows up:

    Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) in /nfs/cust/8/98/40/504898/web/edge/ajaxsearch.php on line 25
    Sorry, search is not available.

    then when i take the text out it goes away. i followed the instructions exactly a couple times and the same thing happened.

    thanks

  1. 1 Nico.Berlee.nl » Archives » Instant Search in Wordpress
  2. 2 Instant Search in Wordpress | WordPress

Leave a Reply