[英]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.