jQuery .load 不加载 swfobject 内容
我正在通过 jquery .load() 将一些内容(不是 HTML 标头或任何内容,只是来自 PHP 的 HTML 格式的内容)加载到 div 中。
它适用于所有东西,除了一些使用 swfObject 动态加载 amCharts PHP 的基于 Flash 的 amCharts (www.amcharts.com)。该文件单独加载,可运行并加载 Flash 图表。使用 .load() 加载时,文件似乎已加载,但脚本未执行且 swfObject 未制定。
现在,我不确定要在这里给你什么代码,所以我只是提供一些围绕它的东西...
所以,在主父级的标题中是侦听导航单击以加载内容的代码(这是我们的 amcharts) :-
$('a.leftNav').click(function() {
page = $(this).attr('page');
metID = $(this).attr('metID');
if($("#mainRight").is(":visible")) { $('#mainRight').hide(200); }
switch(page) {
case 'metrics': $("#mainRight").load("content.php?load=mets", { metID: '5000227' }); break;
}
$('#mainRight').show(300);
});
这样就可以了。加载正确的页面并执行 PHP,如转到页面 content.php?load=mets 所证明的那样。 PHP 生成的该页面上的代码是:-
<div class="amChart" id="chart_views_div">
Chart loading ...那应该是交换的 swfObject 代码,我知道它(我已输出到 PHP 代码生成的文本文件)正在工作。
.load() 和加载的 swfObject 和 JS 通常会发生什么?
I'm loading some content (NOT THE HTML headers or anything, just HTML formatted content from a PHP) via jquery .load() into a div.
It works, perfectly for everything BUT some Flash-based amCharts (www.amcharts.com) dynamically loaded with amCharts PHP, using swfObject. The file, loaded seperately, works and loads the Flash charts. When being loaded in using .load() the file seems to be loaded, but scripts not executed and swfObject not enacted.
Now, i'm not sure what code to give you here, so ill just give some stuff around it...
So, in header of main parent is the code listening for the nav click to load the content (which is our amcharts):-
$('a.leftNav').click(function() {
page = $(this).attr('page');
metID = $(this).attr('metID');
if($("#mainRight").is(":visible")) { $('#mainRight').hide(200); }
switch(page) {
case 'metrics': $("#mainRight").load("content.php?load=mets", { metID: '5000227' }); break;
}
$('#mainRight').show(300);
});
So that works. Loads the correct page and works executing the PHP as proved by going to the page content.php?load=mets. The code on that page generated by the PHP is:-
<div class="amChart" id="chart_views_div">
Chart loading ...
That should be the exchanged swfObject code, which I know (i've outputted to a text file the PHP's code generated) is working.
What happens with .load() and loaded swfObject and JS generally?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当 jquery .load() 完成时,您需要调用一个函数来初始化 swfObject 替换,因为我相信 swfObject 通常会在 window.load 上初始化。
像这样的东西:
You need to call a function to initialise the swfObject replacement when
jquery .load()
has completed as i believe that swfObject would usually initialise on window.load.something like this:
Am Charts 仍然使用 swfobject 1.5
Swfobject 2.x 提供了更多内容,恕我直言,amcharts 应该更新以使用新版本。
2.x 有createswf,在这种情况下应该使用它
Am Charts still uses swfobject 1.5
Swfobject 2.x offers much more IMHO amcharts should update to use the new version.
2.x has createswf which should be used in this case