1
我創建了一個新的wordpress-template-page。這個想法是,當我點擊我的sidebar-div中的鏈接時,它應該從我的content-div中的數據庫加載內容。在一個簡單的PHP頁它的工作原理,但在我的WordPress模板的頁面組合它不工作...在Wordpress中通過XMLHttpRequest加載數據庫內容
這是我的代碼:(精簡版)
<?php // Template Name: Weinkarte
get_header(); ?>
<div id="container-sidebar">
<span id="wineList"></span>
</div>
<div id="sidebar-right">
<li><a href='#' id='1' onclick='loadWine(this.id)'>Click</a></li>
</div>
get_footer();
<script>
function loadWine(id)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("wineList").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","loadWine.php?landID="+id,true); //I think here is probably the fault
xmlhttp.send();
}
</script>
感謝您的幫助! :)
謝謝。現在它工作了! :D – Luca 2013-04-21 15:09:16
歡迎您:) – 2013-04-21 15:40:42