[英]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.