简体   繁体   English

使用$ .getScript回调函数加载脚本

[英]Loading Script using $.getScript callback function

I'm loading the Google Maps API using jquery $.getScript like so 我正在使用jquery $ .getScript加载Google Maps API,如下所示

$.getScript("https://maps.googleapis.com/maps/api/js?async=2&callback=GMapsInit");

You can see that the URL has the callback function GMapsInit . 您可以看到该URL具有回调函数GMapsInit Does the GMapsInit function get called after the script is loaded and executed, or simply after its loaded and not necessarily executed? GMapsInit函数是在脚本加载和执行后,还是只是在加载并不一定执行后才调用?

The callback is called when the script is loaded AND executed. 加载并执行脚本后将调用回调。

This is why you have to use a callback when you load Google Maps. 这就是为什么在加载Google Maps时必须使用回调的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用getScript加载我的脚本 - loading my script using getScript getScript未加载本地脚本 - getScript not loading local script 当使用$ .getScript()加载脚本时,是否可以从使用$ .getScript()加载的脚本中调用父脚本中的函数? - When loading a script with $.getScript() is there a way to call a function in the parent script, from the script being loaded with $.getScript()? 使用$ .getScript加载脚本时的查询字符串参数处理 - Query string parameter handling when loading a script using $.getScript 使用jQuery getScript从PHP脚本调用JavaScript函数 - Call JavaScript Function From PHP Script Using jQuery getScript 在ajax加载回调函数中调用getScript - calling getScript inside an ajax load callback function 结合使用.getScript()和条件函数 - using .getScript() in combination with a conditional function 使用$(document).ready()和$ .getScript()完成页面加载后,加载外部脚本 - Load external script after page is done loading by using $(document).ready() and $.getScript() 如何在使用$ .getScript运行的脚本中访问函数或变量 - How to access a function or variable in a script run with $.getScript $ .getScript没有回调-仅阻止当前脚本或主事件循环? - $.getScript without callback - blocks only current script or main event loop?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM