How to include jquery.js in another js file?

后端 未结 4 749
时光说笑
时光说笑 2020-12-03 14:48

I want to include jquery.js in myjs.js file. I wrote the code below for this.

  var theNewScript=document.createElement(\"script\");
  theNewScript.type=\"te         


        
4条回答
  •  一整个雨季
    2020-12-03 15:26

    The problem is that the script doesn't load instantly, it takes some time for the script file to download into your page and execute (in case of jQuery to define $).

    I would recommend you to use HeadJS. then you can do:

    head.js("/path/to/jQuery.js", function() {
       $.get('myfile.php');
    });
    

提交回复
热议问题