我创建了一个新的WordPress的模板页面。 我们的想法是,当我点击我的侧边栏DIV的链接,它应该载入从我的内容DIV的数据库内容。 在一个简单的PHP页它的工作原理,但在我的WordPress模板的页面组合它不工作...
这是我的代码:(精简版)
<?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>
谢谢你的帮助! :)