doufuhuang6981 2012-04-18 10:33
浏览 32

当<applet>标记加载ajax时,它无法初始化

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 :/

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。