Question

I'm loading Google Maps API dynamically using this function:

App.prototype.loadScript = function(src) {
  $(document.createElement("script")).attr({
    type: "text/javascript",
    src: src
  }).appendTo("body");
};

I pass this URL as the argument:

"//maps.googleapis.com/maps/api/js?v=3.8&sensor=false&language=" + locale + "&callback=window.app.googleMapsCallback"

It works fine the first time I load the page, and the callback fires. However, when I reload the page on Android, window.app.googleMapsCallback does not fire. It works fine in Chrome and in the iOS browser.

It's like the script is cached, and is just not reloaded again. I've tried adding a timestamp parameter to the URL but that didn't help.

How can I make sure the callback always fires?

UPDATE:

Upon further testing, clearing the cache and reloading doesn't work either. I have to clear out all browser data (via Settings -> Applications -> Manage applications) to reload the page successfully.

Using a top level function as a callback makes no difference.

There are no JavaScript errors on reload.

I should mention that I'm using an HTC Evo 4G with Android 2.3.4, and my application is built with jQuery Mobile.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top