Forum Discussion
Exporting Variables into a Google Spreadsheet
Hi Laura -
The Jquery needs to be loaded ahead of the script fire. There is some time-lag between the creation of the object and the actual load and initialization of the library. So if you try to call something immediately, it'll probably fail. I usually try to load it on the base layer then call another layer on a delay to execute. This provides 3 to 5 seconds of lead time which seems to be enough to consistently get the library in.
If you were on a dial-up connection, this could be close.
The other thing you could try is a setInterval call that looks for something jquery unique to load before firing your ajax function and canceling the interval. This is probably better than the delay as it would still work if jquery took forever to load.
Like looping to check for this every second or so:
if (typeof jQuery!='undefined') { //run your jquery ajax call and cancel the interval}