When I load a library from a function it doesn't load and even crashes the page!
What's up with that??
HTML head:
<script type="text/javascript" src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY"></script>
<script type="text/javascript">
// --- LOADING LIKE THIS WORKS FINE ---
// jQuery is completely loaded
function jqueryLoaded() {
$("body").css("background-color","orange");
}
google.load("jquery", "1.4.3");
google.setOnLoadCallback(jqueryLoaded);
// --- LOADING FROM AN EVENT DOES NOT WORK?? ---
// jQuery UI is completely loaded
function jqueryUILoaded() {
$("body").css("background-color","green");
}
function loadJqueryUI() {
alert("load jQuery UI now..");
google.load("jqueryui", "1.8.6");
google.setOnLoadCallback(jqueryUILoaded);
}
// with a setTimeout it doesn't work either..
// setTimeout("loadJqueryUI()", 2000);
</script>
HTML body:
<input type="button" value="load jQuery UI" onclick="loadJqueryUI()"/>