setTimeout does not work

后端 未结 4 804
攒了一身酷
攒了一身酷 2021-02-06 08:44

I want to load an OWL file before executing other (visualisation-)scripts. To do this I tried everything from

$(document).ready

to

<         


        
4条回答
  •  我在风中等你
    2021-02-06 09:02

    Try this:

    function visualize (file) {
      if (!file)
        {setTimeout(function(){visualize(file);}, 2000)}
      else
        {jQuery(function($){visFeaturePool.init(file)})}}
    

    This way you are giving setTimeout an anonymous function that will be executed when scheduled, and you can pass parameters to visualize using a closure like file.

提交回复
热议问题