After over an hour of trying to get it to work I'm thinking it's because of cross domain policies, but I really thought this would work. I can't find a lot of info on it either. But, here is my issue. I have a site called http://mysite.com and then I include a 3rd party script (what im writing) and its at http://supercoolsite.com/api/script.js and this script needs to dynamically load the google maps api at: http://maps.google.com/maps/api/js?sensor=false before it runs. Well, i figured this code would work:
But my response in my console is:
api.js:408 done loading api.js:115 test api.js:310 Uncaught ReferenceError: google is not defined
test" is at the top of the
echo file_get_contents() into a
googlemaps.php file we host. About to try this as we speak, but, if possible, a way to do it with pure JS would be awesome.
P.S. I also tried adding jQuery, then doing
getScript(), and it still didnt work
-- UPDATE --
See this fiddle: http://jsfiddle.net/ycMCa/2/
You'll see that you get the error in your console:
Uncaught TypeError: undefined is not a function
Despite that the
You just have a minor error:
fileref.onload = callback();
This will call
callback immediately and assign its return value to
It should be
fileref.onload = callback;
You also should add the handler before you set the source (just in case).
©2020 All rights reserved.