1) Script Title: Dynamic Ajax Content
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm
3) Describe problem: This is a problem I've had for some time. I'm using a Ajax /php model but when loading pages .js files are not "linked / initialized". I thought the loadobjs() would fix that.
the code in menu:
the "ChangeMain" routine was an earlier version but I'd like to keep it. It consists of:PHP Code:<?php
if ($userID == 1){
echo "<button class='Menu' onclick=\"ChangeMain('Pg_People.php', 'HumanResources.js')\" value=\"People\">Clients</button><br/>";
echo "<button class='Menu' onclick=\"ChangeMain('Pg_Companies.php', 'HumanResources.js')\" value=\"Cos\">Companies</button><br/>";
echo "<button class='Menu' onclick=\"ajaxpage('Pg_Cases.php', 'Main'); loadobjs('./Code/Cases.js')\" value=\"Cases\">Cases</button><br/><br/>";
echo "<button class='Menu' onclick=\"ChangeMain('Pg_Test.php', 'Cases.js')\" value=\"Cos\">Test 1</button><br/>";
echo "<button class='Menu' onclick=\"ajaxpage('Pg_Test.php', 'Main'); loadobjs('./Code/Cases.js')\" value=\"Cases\">Test 2</button><br/><br/>";
}
?>
The external page calls a function (from a button) that runs a js "alert()"Code:function ChangeMain(NewMain, jsfile){ xmlHttp=GetXmlHttpObject() if (xmlHttp==null){ alert ("Browser does not support HTTP Request") return } try{ ajaxpage(NewMain, 'Main'); loadobjs(jsfile); } catch(err){ alert("Error: "+err.description) } }
The "ajaxpage()" function works perfectly. "loadobjs()" doesn't seem to do anything.
Pg_Test.php looks like this:
And finally Cases.js looks like this:HTML Code:<?php /* * Created on May 27, 2009 * */ session_start(); ?> <html> <head> </head> <body > <div id='CaseOverview'> <form> <input type="button" id='AdvFilter' value="Test Load" onclick="TestCaseLoad()" align="center"/> </form> </div> </body> </html>
I'm at a loss at to why it doesn't work. Anyting you can offer is greatly appreciated !!Code:funtion TestCaseLoad(){ alert("Cases.js is loaded") }
Sorry I'm a moron. Missed typed. function!!



Reply With Quote
Bookmarks