Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX Content not using Loaded Javascript Source
    primarykey
    data
    text
    <p>I have a file called incident.php that loads my main page. This includes header, footer and sidebar. The content of the page I am loading from incident.inc.php. As this is ever changing I have opted to use AJAX to load this content and reload at 30 second intervals allowing it to be left open as a dashboard. </p> <p>For the dashboard code I am using Twitter Bootstrap and this dashboard: <a href="https://wrapbootstrap.com/theme/metro-admin-template-WB0KDM51J" rel="nofollow">https://wrapbootstrap.com/theme/metro-admin-template-WB0KDM51J</a></p> <p>This dashboard has multiple JS files that it loads at the bottom of each page. I have found that when I am loading the content through AJAX that it doesn't behave properly along with the loaded javascript source files. I have seen multiple ways of getting a script to run at the time the Ajax content loads, but have not seen how I can get it to recognize these 20 or so javascript files that the dashboard includes. The only work around I have found is to include all of these javascript files within the incident.inc.php which I assume is not the proper way to do it. </p> <p>I am looking for the best practice on how to have content loaded from AJAX to utilize the included Javascript files in the originating file (incident.php). </p> <p>My AJAX call within incident.php is as follows. </p> <pre><code>(function($){ $.ajaxSetup( { cache: false, beforeSend: function() { $('#incidents').hide(); $('#loading').show(); }, complete: function() { $('#loading').hide(); $('#incidents').show(); }, success: function() { $('#loading').hide(); $('#incidents').show(); } }); var $container = $("#incidents"); $container.load("incident.inc.php"); var refreshId = setInterval(function() { $container.load('incident.inc.php'); }, 30000); })(jQuery); </code></pre> <p>I know that there has to be a better way to do this. I just can't seem to pinpoint exactly how to do it in this situation. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload