请参阅http://www.elitedeafpoker.com/dev/poker-players.html - 我尝试使用 AJAX/jQuery 在此页面上加载三个内容,但它不会加载内容(最终,我想使用加载每个内容JSON 调用),但首先我想看看这是否有效,然后再深入使用 JSON。如果这不是使用 AJAX/jQuery 加载内容的最佳方式,请告诉我 - 不胜感激。
HTML
<article class="span3">
<ul class="list-1">
<li class="navlinks" id="pokerplayers"><a href="#pokerplayers">EDPS Poker Players </a></li>
<li class="navlinks" id="playerofthemonth"><a href="#playerofthemonth">Players of the Month</a></li>
<li class="navlinks" id="playeroftheyear"><a href="#playeroftheyear">Players of the Year </a></li>
</ul>
</article>
<article class="span9">
<div id="content">
Contents to load...
</div>
</article>
Javascript(内容.js)
$(document).ready(function(){
$("#pokerplayers").click(function(e){
var page = $(this).attr('href, word: hash');
e.preventDefault();
$("#content").load("content.html #pokerplayers");
$(this).hide().fadeIn("slow");
});
$("#playerofthemonth").click(function(e){
var page = $(this).attr('href, word: hash');
e.preventDefault();
$("#content").load("content.html #playerofthemonth");
$(this).hide().fadeIn("slow");
});
$("#playeroftheyear").click(function(e){
var page = $(this).attr('href, word: hash');
e.preventDefault();
$("#content").load("content.html #playeroftheyear");
$(this).hide().fadeIn("slow");
});
});
内容.html
<div id="pokerplayers">
<p class="content-text">Poker Players</p>
</div>
<div id="playerofthemonth">
<p class="content-text">Player of the Month</p>
</div>
<div id="playeroftheyear">
<p class="content-text">Player of the Year</p>
</div>