I've got a page with a preview image on it, and when you click the preview image, JQuery replaces it with a Java applet using the ajax load() function. The applet comes up alright (it's netlogo) and seems to find the .nlogo file it's looking for.
This .nlogo filename is passed to the applet with a <param>
tag. The applet is generic, and it will load any .nlogo file and run it just like the NetLogo desktop application.
It doesn't display anything however. I know it's finding the file, because when I pass it a bad filename, it throws an error, and right now it's not throwing one.
It works fine if the code is just placed in the html normally, but when it is loaded with ajax the applet does not initialize correctly.
I'm guessing that the applet is waiting for some kind of page-finished-loading event that's not ever going to happen. Is there any way I can fake that message?
The code is distributed all over the place but here are the relevant parts
The div I'm messing with
<div id="previewDiv">
Click the image to run the netlogo applet in your browser.<br>
<img id="previewImage" src='<?php echo($modelPath . $previewFile); ?>' style="margin: 8px;" />
</div>
The JQuery that replaces the preview image with the applet
$(document).ready(function(){
$("#previewImage").click(function(){
$("#previewDiv").load("appletcode.php?mid=<?php echo $mid; ?>");
});
});
The applet code that get's sent down for the ajax request
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include "library.php";
connectdb();
$mid = mysql_real_escape_string($_GET['mid']);
$sql = "SELECT * FROM models WHERE modelId=$mid;";
$result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
$row = mysql_fetch_array($result);
$version = $row['netlogoVersionStr'];
$nlogocode = $row['netlogoFile'];
$appletWidth = $row['appletWidth'];
$appletHeight = $row['appletHeight'];
$modelPath = "/complexityexplorer/netlogo/userfiles/$mid/";
$nlogoFilePath = $modelPath . rawurlencode($nlogocode);
?>
<applet code="org.nlogo.lite.Applet"
archive="/complexityexplorer/netlogo/<?php echo rawurlencode($version) ?>/NetLogoLite.jar"
width="<?php echo $appletWidth ?>" height="<?php echo $appletHeight ?>">
<param name="DefaultModel"
value="<?php echo $nlogoFilePath ?>">
<param name="java_arguments"
value="-Djnlp.packEnabled=true">
</applet>
God I hope someone has a shred of knowledge about this :/