API key validation through GSS

Jun 20, 2010 at 4:58 PM

For my next addition to this project, I've decided that I want to incorporate Google AJAX Search API key validation into GSS. For those of you who don't know, GSS was my senior project at DePauw University this past Spring to finish up my computer science major. It allows you to set up a Google Search Box on your page without the hassle of dealing with Google's thicket of documentation/api code. For GSS, this means that the start-up code will go from


<script src="http://…/jquery-1.4.2.js" type="text/javascript"></script>
<script src="http://…/jquery.gss-0.1.3.js" type="text/javascript"></script>
<script src="http://…/yourAPIkey" type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
google.load("search", "1");

to something like

<script src="http://…/jquery-1.4.2.js" type="text/javascript"></script>
<script src="http://…/jquery.gss-0.1.3.js" type="text/javascript">
$("#myDiv").GoogleWebSearch({ key : "yourAPIkey" });

Cool huh? GSS just keeps getting easier to use! Basically, inside of GSS I will need to programmatically write these extra script tags to the web page. I've never done this, but I know there will need to be some careful consideration for the order in which they are loaded. For example, this validation with Google needs to happen before any of the GSS code is executed. I've done quite a bit of reading. One solution is to use


. This seems like it would work, but it seems so kludgy! I'll keep up the reading for now and post any techniques I discover. Any suggestions would be much appreciated, especially from those of you who already have downloaded and taken a look at the project! -Andrew