1

Hi,

I have this function on jquery:

<script type="text/javascript">
   // jQuery Document
   $(document).ready(function () {
    function loadlog() {
     $.get("logs.html', function (data) {
      $("#container").html(data);
     });
    }
   
    loadlog(); 
   });
  
  //start javascript
  var whatever= something;
</script>

I want the javascript part to start right AFTER loadlog(); has finished loading all its stuff so #container wont be empty. Most of the time it does but seems like it will often takes too long in reading the external file and it loads it after the javascript part executes I dont want. What can I do?

Thank you.

Cain Nuke
  • 2,843
  • 5
  • 42
  • 65
  • Where you have `loadLog()` defined, that _is_ where your previous function call has ended and you should add more code. If you want, you could wrap it in a `Promise`, call `resolve` after `loadLoad` and then `await` that promise, but why make it so complicated? You already _know_ the answer. – somethinghere Nov 10 '21 at 22:22
  • no, I dont know it. Thats why I asked. – Cain Nuke Nov 11 '21 at 18:40
  • "I want the javascript part to start right AFTER loadlog(); " - Yes you do. Put your code _after_. – somethinghere Nov 12 '21 at 17:02

0 Answers0