views:

288

answers:

2

while coding javascript and ajax, there is no proper documentation for this function? i searched this term using api src="http://www.google.com/jsapi " and searchControl.execute("abhilashm86");

how does this google.setOnLoadCallback(initalize) called internally? is this function just for a new search term when user clears previous search and starts new one? How exactly this google.setOnLoadCallback(initalize) gets trigerred?

+1  A: 

Your initialize function will be called when your document (including the Google API) is fully loaded. So you should wrap any code that uses the API in the function you pass in:

E.g.

google.setOnLoadCallback(function()
{
   var searcher = new google.search.SearchControl();
   // More code that depends on the API.
});
Matthew Flaschen
A: 

The documentation says:

Use google.setOnLoadCallback to register the specified handler function to be called once the document loads instead of GSearch.setOnLoadCallback.

Jason Hall