【发布时间】:2023-01-30 00:49:20
【问题描述】:
我有一些动态 XML - 在 PHP 脚本中生成。 该脚本采用单个参数“p”——代表“pagenum”。 这个想法是显示分页数据 - 允许用户选择下一页/上一页数据。
我采用什么方法来使用新页面更新数据 - 我的屏幕是否有可能更新而必须通过 HTTP 重新加载页面?
这是我的主页的 sn-p - 基本上我正在使用新的 GET 参数重新加载整个页面。 (p=1,p=2 等)。 (可以看出,我的主页也恰好是 PHP - 但除了获取参数之外,我确实做了很多事情)。
<?php
header('Content-Type: text/xml; charset=utf-8');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$p=1;
if (isset($_GET['p'])) {
try { $p=(int)$_GET['p']; } catch(Exception $ex) { ; }
}
if (isset($_GET['debug'])) { $debug="yes"; } else { $debug="no"; }
?>
[...]
<xf:model>
<xf:instance src="data.php?p=<?=$p?>"/>
</xf:model>
</head>
<body>
<xf:repeat ref="videos/video">
<details>
<summary>
<span class="title"><xf:output value="title"/></span>
</summary>
<p>
<xf:output value="description" mediatype="text/html"/>
</p>
</details>
</xf:repeat>
编辑:添加虚拟数据源以供参考。
<?php
header('Content-Type: text/xml; charset=utf-8');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (isset($_GET['p'])) { $p=(int)$_GET['p']; } else { $p=1; }
echo "<data xmlns=''>\n";
echo "<videos>\n";
switch ($p) {
case 1:
echo "<video><title>Macbeth</title></video><video>Malformed</video>";
break;
case 2:
echo "<video><title>Hamlet</title></video><video>SPACE 2003</video>";
break;
case 3:
echo "<video><title>Romeo And Juliet</title></video><video>Back to the Feature</video>";
default:
echo "<video/>";
}
echo "</videos>\n";
echo "</data>\n";
?>
【问题讨论】:
-
好的 - 到达那里 - 我可以使用“提交”元素来更改 URL。我唯一需要解决的问题是如何替换 URL 中的查询参数。我想我需要使用“资源”属性 - 但我仍在研究如何将此与“替换”属性结合使用......一旦我有更多进展,我会更新。