[英]Load AJAX content from a link on a different page
我想创建一个链接,我们将其称为“星期一的时间表”。 当您单击该链接时,它将加载“时间表”页面,并且“ ajaxoutput” div会预先填充“ view_games_monday.php”,如下面的函数所示。
当前,与以下功能有关的链接位于页面“ Schedule”上,该页面是具有“ ajaxoutput” div的SAME页面。
document.getElementById('games_monday').onclick = function()
{
callPage('view_games_monday.php',document.getElementById("ajaxoutput"));
}
<a href="#" id="games_monday">monday</a>
<div id="ajaxoutput">
</div>
那么,如何设置“星期一的时间表”链接,以在“时间表”页面加载“ ajaxoutput” div中预先填充的“ view_games_monday.php”? 我的问题是“星期一的时间表”链接不在“时间表”页面上。
很抱歉,所有报价都想弄清楚。
谢谢您的帮助。
我已经尝试了以下方法,可以加载“计划”页面,但是没有正确的ajax输出:
document.getElementById('schedule_monday').onclick = function()
{
location = "http://mydomain.com/schedule";
this.document.location.href = location;
window.onload = callPage('http://mydomain.com/view_games_monday.php',document.getElementById("ajaxoutput"));
}
根据我们的评论讨论,这是基于对所需内容的理解而提出的建议。
您只需要一个页面index.php
。 这是非常基本的,但可以说明:
<?php
$scheduleDay = (isset($_GET['day']) ? $_GET['day'] : 'monday');
if( $scheduleDay == "monday" ){
print 'stuff for monday goes here';
}
else if( $scheduleDay == "tuesday" ){
print 'stuff for tuesday goes here';
}
然后,在导航菜单中,只需使用: index.php?day=tuesday
等。
当php文件检测到日期时,它将打印相应的信息。 甚至不需要javascript。
您可以像我之前提到的那样将其设置得更奇特,然后将所有时间表打印到页面上,并使用javascript仅显示一天,但是我想这个例子就是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.