I'm having major problems. I have a page called dashboard.php but the actual page div (ID = #dashboardcontainer) is empty as I am filling the content with this script:
$('#dashboardcontainer').load('functions/pages/dashboard/dashboard_admin.php');
then I tried:
$.getScript("assets/plugins/jquery-1.8.2/jquery-1.8.2.min.js", function(){
$('#dashboardcontainer').load('functions/pages/dashboard/dashboard_admin.php');
})
However, the page I am wanting to "inject" actually has Javascript in it. The problem is, the above javascript's .load() doesn't load the javascript in the file.
I've tried lots of other examples from the following posts but they don't work at all. The javascript isn't actually loading.
jQuery .load() / .ajax() not executing javascript in returned HTML after appended
$.get('partial.html', function(result){
$result = $(result);
$result.find('#content').appendTo('#new_content');
$result.find('script').appendTo('#new_content');
}, 'html');
= No javascript firing.
jQuery ajax load() java script not executing?
$("loadStuffHere").load("xyz.html"); $.getScript('js/xyz.js');
= Still no javascript firing.
I can't use lots of PHP includes as I receive conflicts which stops my page from rendering correctly.
I've also tried using some sort of Json thing to hide and show dom elements but I hate how complex it is to modify and insert new data.
Is there any simple (this term doesn't seem to exist in the web development dictionary) way I can actually inject a web page that contains it's own javascript in the same way a PHP include would render it?
Here is the PHP page I am trying to inject:
<?php
echo '<script type="text/javascript">alert("This is the sub-page");</script>';
?>