I am having a problem loading the Google AJAX APIs in response to user input instead of when the page loads.
This works:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("search", "1");
google.setOnLoadCallback(function() { alert("loaded"); });
</script>
But this doesn't:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
function clicked() {
google.load("search", "1");
google.setOnLoadCallback(function() { alert("loaded"); });
}
</script>
The clicked function is a handler for a simple link.
Does anyone know why?