google-ajax-api

google.setOnLoadCallback with jQuery $(document).ready(), is it OK to mix?

笑着哭i 提交于 2019-11-26 12:06:27
问题 I\'m using Google Ajax API and they suggest I use google.setOnLoadCallback() to do various things related to their API but I\'m using also jQuery\'s $(document).ready() to do other JS things, not related to Google API. Is it safe to mix these two approaches in one document? I did not notice any problems yet but I suppose it\'s a matter of scale. 回答1: You pretty much have to do this: google.setOnLoadCallback(function() { $(function() { // init my stuff }); }); You can't do $(document).ready()