I am trying to use google ajax apis in the chorme extension "content script". On a regular html page, I would just do this:
<script src="http://www.google.com/jsapi"></script> <script> google.load("language", "1"); </script>
But since I am trying to load a dynamic library dynamically from js code, I tried:
script = document.createElement("script"); script.src = "http://www.google.com/jsapi"; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); google.load('language','1')
but the last line causes the following error:
Uncaught TypeError: Object
It's funny when I go into the same " google.load('language','1') " in the chrome js console, it works as intended ...
I also tried with jquery .getScript() , but the same problem persists ...
Does anyone know what could be the problem and how can this be solved?
Thank you very much in advance!
source share