简体   繁体   中英

how run document ready in external file js

i have a function for select data in external file js

  function show_all() {
     work = "select";
      $.ajax({
          type: "POST",
          url: "server.php",
          data: "work="+work,
          success: function(data) {
              $("#boxtop").html(data);  
              $('#boxtop').animate({
              scrollTop: $('#boxtop').get(0).scrollHeight}, 0);
          } 
      });  
  }

and document ready work in html index but dont work in external file js

$(document).ready(function(e) {
   show_all();
});

If I understand you right, you need to add this line to your index.html

<script type="text/javascript" src="yourscript.js"></script>

in a head section, where in src you should put a path to your external file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM