对于我的组件,我制作了进行大量检查的飞行前检查页面,但我不希望一开始就运行检查,有时我只想运行检查。
所以我使用ajax,但这不是解决方案我从joomla框架中丢失了我的所有类,有没有更好的方法来解决这个问题?
我的 tmpl/default.php 看起来像这样:
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
<button onClick="xmlserverinfo()">XMLserver check</button>
</div>
<div id="j-main-container" class="span10">
<?php
// some php stuff to get the variables
?>
<div id="preflight">
<table>
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td colspan="3">XML server status</td>
</tr>
<tr>
<td>Naam</td>
<td>Url</td>
<?php if ($proxy == '1')
{
echo "<td>via proxy</td>";
}?>
<td>Status</td>
</tr>
<div id="xmlservers"></div>
</tbody>
<snip>
这是我用来刷新我的 div 的 java 脚本,包括 ajax.js
function xmlserverinfo()
{
var xmlhttp;
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("xmlservers").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","components/com_hccxmlbeheer/views/preflightcheck/tmpl/xmlservers.php",true);
xmlhttp.send();
}
这是构建我的表的 xmlservers.php,这就是我在我的 div 中想要的:
<?php
/**
* @package Joomla.Administrator
* @subpackage com_hccxmlbeheer
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die;
// php stuff to get variables
foreach ($xmlservers as $xmlserver)
{
echo "<tr>";
echo "<td>$xmlserver[0]</td>";
echo "<td>$xmlserver[1]</td>";
if ($proxy == '1')
{
echo "<td>ja</td>";
}
$echotest = HCC::echo_test($xmlserver[1], $pluginnaam, $plugincat, '0');
if ($echotest['Status'] == 'TRUE')
{
echo "<td bgcolor=\"green\">Oke</td>";
}
else
{
echo "<td bgcolor=\"red\">mislukt</td>";
}
echo "</tr>";
}
if ($proxy == '1')
{
foreach ($xmlservers as $xmlserver)
{
echo "<tr>";
echo "<td>$xmlserver[0]</td>";
echo "<td>$xmlserver[1]</td>";
if ($proxy == '1')
{
echo "<td>nee</td>";
}
$echotest = HCC::echo_test($xmlserver[1], $pluginnaam, $plugincat, '1');
if ($echotest['Status'] == 'TRUE')
{
echo "<td>Oke</td>";
}
else
{
echo "<td>mislukt</td>";
}
echo "</tr>";
}
}
?>
我究竟做错了什么 ?