PDA

View Full Version : Resolved Dynamic Ajax Content :: loadobjs doesn't seem to work



JohnDMcQ
05-27-2009, 04:23 PM
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:

<?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 "ChangeMain" routine was an earlier version but I'd like to keep it. It consists of:

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 external page calls a function (from a button) that runs a js "alert()"

The "ajaxpage()" function works perfectly. "loadobjs()" doesn't seem to do anything.
Pg_Test.php looks like this:


<?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>

And finally Cases.js looks like this:

funtion TestCaseLoad(){
alert("Cases.js is loaded")
}

I'm at a loss at to why it doesn't work. Anyting you can offer is greatly appreciated !!




Sorry I'm a moron. Missed typed. function!!