Php AJAX:Reload以输出flashobj
我用这些来输出我的简单仪表板。我正在使用AJAX重新加载我的DIV并返回到DIV1,并计划在DIV2中显示图表 Im使用settimeout函数将超时设置为1分钟。每分钟它都会刷新从数据库中选择的更新图表的DIV1和DIV2 我的问题是我不能正确地显示DIV2图表。它没有显示,FireBug中没有显示错误。它只是不显示。我做错了什么。或者我应该遵循什么方法 下面是index.php的代码 try.php是用于图表的。。第二组Php AJAX:Reload以输出flashobj,php,ajax,Php,Ajax,我用这些来输出我的简单仪表板。我正在使用AJAX重新加载我的DIV并返回到DIV1,并计划在DIV2中显示图表 Im使用settimeout函数将超时设置为1分钟。每分钟它都会刷新从数据库中选择的更新图表的DIV1和DIV2 我的问题是我不能正确地显示DIV2图表。它没有显示,FireBug中没有显示错误。它只是不显示。我做错了什么。或者我应该遵循什么方法 下面是index.php的代码 try.php是用于图表的。。第二组 您使用的代码是什么?为什么要使用$var??只需删除变量并直接放入浏览
您使用的代码是什么?为什么要使用$var??只需删除变量并直接放入浏览器。。。请-您只需要在标记中包含PHP。。。请注意,这可能无法解决您的问题,但以当前的方式执行此操作是疯狂的,因为它只是我代码的一部分。我在连接不同的代码,这就是原因。我只是隔离了导致我的问题的部分。@Sid即使您连接了不同的HTML位,将这些单独的部分存储在单独的文件中并包含它们会更有效,因为这样它们就不会一次全部加载到PHP的内存空间,而是写入输出缓冲区并动态发送到客户端。它还可以略微加快响应时间,当然也可以使编辑器/IDE中的代码更容易用于语法高亮显示,并且避免必须跳过引文/文字$S等等。我只需要解决我手头的问题谢谢
<?
$var = "<html>
<head>
<script language='javascript'>AC_FL_RunContent = 0;</script>
<script language='javascript'> DetectFlashVer = 0; </script>
<script src='AC_RunActiveContent.js' language='javascript'></script>
<script language='JavaScript' type='text/javascript'></script>
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript'>
var i=0 ;
window.onload=function(){f()};
function showUser(str)
{
str = str + '';
if (str=='')
{
document.getElementById('div1').innerHTML='';
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById('div1').innerHTML=xmlhttp.responseText;
}
}
var1 = xmlhttp.open('GET','query.php?q='+str,true);
xmlhttp.send();
}
function showGr()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp2=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp2=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp2.onreadystatechange=function()
{
if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
{
document.getElementById('div2').innerHTML=xmlhttp2.responseText;
}
}
xmlhttp2.open('GET','try.php',true);
xmlhttp2.send();
}
function MsgBox (textstring) {
alert (textstring) }
function f() {
if (i==10)
{
i=0;
}
i = i + 1;
showUser(i);
showGr();
//MsgBox(i.toString());
setTimeout('f();',10000);
}
</script>
</head>
<body>
<br />
<div id='div1'> /* 1st Div */ </div>
<div id='div2'> /* 2nd Div */ </div>
</body>
</html>
";
echo $var;
?>
<?
$var = "
<script language='JavaScript' type='text/javascript'>
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2',
'width', '400',
'height', '250',
'scale', 'noscale',
'salign', 'TL',
'bgcolor', '#777788',
'wmode', 'opaque',
'movie', 'charts',
'src', 'charts1',
'FlashVars', 'library_path=charts_library&xml_source=gen_xml.php?q=1',
'id', 'my_chart',
'name', 'my_chart',
'menu', 'true',
'allowFullScreen', 'true',
'allowScriptAccess','sameDomain',
'quality', 'high',
'align', 'middle',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'play', 'true',
'devicefont', 'false'
);
</script>
";
echo $var;
?>