javascript - Wait until <script> finishes loading before executing next step -


i trying code execute in correct order. first need add google maps code dom using: $('body').append('<script defer src="https://maps.googleapis.com/maps/api/js?key=y2e3g8n-jat0gpxpuhr9mq8zj8uysbv4&callback=createmap"></script>');

then need reset center of map when new selection made list: map.setcenter({lat: latitude, lng: longitude});

right setcenter() doesn't work first time run it, presumably because callback function createmap() has added dom, script has not finished. there way can wait until script finishes executing before running setcenter()?

the callback createmap "wait until script finishes executing before running setcenter()". that's callback used for. without showing actual code (and not in comment) of trying , how, can't you.

now understand if code super secret can't show us. in case re-read part of starts " without showing actual code"


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -