简体   繁体   English

如何在外部文件js中运行文档就绪

[英]how run document ready in external file js

i have a function for select data in external file js 我有一个用于在外部文件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 并在html索引中记录就绪工作,但不在外部文件js中工作

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

If I understand you right, you need to add this line to your index.html 如果我理解正确,则需要将此行添加到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 在头部分的src中,您应该在其中放置外部文件的路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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