Note: '?' means that given parameter is optional.

Additional detail available at the Google AJAX Search API Class Reference

Remember, options for each given constructor are completely optional. For example, this will get you up and running:



Only call modifiers after initializing at least one GoogleSomethingSearch from above. If you don't you'll get errors. These affect all Searchers initialized.

$().setTimeoutInterval(string); //short, medium, or long
$()setOnKeepCallback(object, method, opt_keepLabel?);
$().setResultSetSize(string); //small, large
$().setSearchCompleteCallback(object, method);
$().setSearchStartingCallback(object, method);

Search Form Only
Will probably be deleted with next version.

$().SearchForm(enableClear, element); //true, false
$().setOnSubmitCallback(object, method);
$().setOnClearCallback(object, method);

Not really useful unless you're tweaking or debugging the plug-in.

$.warn(string, obj);

GLOBAL options members
execute str
timeoutInterval { "short" , "medium" , "long" }
onKeepCallback object, method, (str) optkeepLabel_
searchStartingCallback object, method
noResultsString str

INDIVIDUAL options members
resultSetSize { "small" , "large" } also global modifier
searchCompleteCallback object, method also global modifier
userDefinedLabel str
userDefinedClassSuffix str
linkTarget { "_blank" , "_self" , "_top" , "_parent" } also global modifier
noHtmlGeneration n/a
queryAddition str
resultHtml result object
gotoPage page

siteRestriction str (WebSearch, BlogSearch, NewsSearch, ImageSearch)
centerPoint str (LocalSearch)
resultOrder { "date" , "relevance" } (VideoSearch, BlogSearch, NewsSearch, PatentSearch)

Searcher Options
expandMode {"closed" , "open" , "partial" }
resultsRoot DOM element
setVideoResultsTbHeight int (less than 100)
setImageResultsTbHeight int (less than 100)

Draw Options
inputElement input Element (this requires some extra work to set up)
drawMode {"linear" , "tabbed" }
searchFormRoot DOM element

Custom Control (Raw Search) needs searchCompleteCallback parameter
customControl {true, false}

Here is an example of using raw search results:

    	$("#myDiv").GoogleNewsSearch({ expandMode : "open", customControl : true, searchCompleteCallback : { object : document, method : function() {
				$.each(theNewsSearch.results, function(i, val) {
					$("#myOtherDiv").append("<i>" + val.titleNoFormatting + "<\/i><br>" + val.content + " - " + val.publisher + "<br><br>");
    	}, execute : "American Idol" });

Below is an example of a fully-loaded options variable. Composite options elements like onKeepCallback require a further level of JSON. A good general method for sending options is to look at Modifiers above and remove the word set. However, notice when using the Constructor, you need to send searchStartingCallback as its own JSON object. With the setSearchStartingCallback, you send parameters for each the object and method sub-parts.

var options = {
    timeoutInterval : "small",
    onKeepCallback : {
            object : window, 
            method : function() { alert('hi'); }, 
            opt_keepLabel : "myLabel"
    resultSetSize : "large",
    linkTarget : "_blank",
    searchCompeteCallback: {
            object : window,
            method : function() {
    searchStartingCallback : {
            object : window,
            method : function() {  
    noResultsString : "Couldn't find any results!"

Last edited Jul 9, 2010 at 8:45 PM by asporter, version 1


No comments yet.