Funky world of Juha

Bizarre and funky world of Juha

Google AJAX Search with jQuery August 3, 2010

Filed under: Google,jQuery — juhq @ 8:12 am

This is just a simple and quick(!) jQuery implementation of

It’s not perfect, but seems to work.

<!-- SEARCH FORM -->
<form action="" method="get">
<!-- HTML5 SEARCH BOX!  -->
<input type="search" id="search-box" name="q" results="5" autocomplete="on" />
<input id="search-submit" type="submit" value="Search" />
<div id="search-area" style="position:relative;">
<div id="search-results">
<div id="search-results-pointer"></div>
<div id="search-results-content"></div>

<script type="text/javascript" src=""></script>
<script type="text/javascript">
google.load("jquery", 1.4.2);

function googlesearch() {
	if(typeof(searchLoaded) == "undefined") {
		var searchLoaded = true; // set searchLoaded to "true"; no more loading!

		var searchBox = $("input#search-box");

		// google interaction
		var search = new,
		control = new,
		options = new;

		// set google options

		// set search options

		// set search controls
		control.setNoResultsString("No results were found.");

		// add listeners to search box
		searchBox.bind("keydown", function() {
			var value = searchBox.val();
			if(value) {

3 Responses to “Google AJAX Search with jQuery”

  1. Vladica Savic Says:

    How to limit this search only to my website?
    I try with setSiteRestriction but it seems that this options is useless?

  2. John Says:

    I too would like to know how to limit the search to a specified website for local searches only. The original article at does this but even using the hidden form code, the ajax returns global results.
    Is there something in the jquery that needs tweaking to allow a site -only search?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s