使用AJAX/jQuery加载内容

使用AJAX/jQuery加载内容,jquery,Jquery,请参阅-我尝试使用AJAX/jQuery加载此页面上的三个内容,但它不会加载内容(最终,我希望使用JSON调用加载每个内容),但首先我想在深入使用JSON之前看看这是否有效。如果这不是使用AJAX/jQuery加载内容的最佳方式,请告诉我-非常感谢 HTML content.html <div id="pokerplayers"> <p class="content-text">Poker Players</p> </div> <div

请参阅-我尝试使用AJAX/jQuery加载此页面上的三个内容,但它不会加载内容(最终,我希望使用JSON调用加载每个内容),但首先我想在深入使用JSON之前看看这是否有效。如果这不是使用AJAX/jQuery加载内容的最佳方式,请告诉我-非常感谢

HTML

content.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>

扑克玩家

月度最佳球员

年度最佳球员


它对我有效,你是通过打开文件运行它还是使用服务器运行它?这样运行时,它不起作用:

file:///C:/Users/xxx/Desktop/stackoverflow/index.html 

但是当我把它上传到我的服务器上时,它工作得很好,看

是的,它现在可以工作了,但是左导航在点击其中一个链接后消失了。它应该加载到content id div。出了什么问题?$(this.hide().fadeIn(“slow”);有了这句话,你就告诉它消失,只需把它注释掉或删除。我删除了它们,左边的导航仍然消失了。肯定还有别的东西,我不知道。如果你在我提交的网站上查看源代码,你可以看到我在做什么和我删除了什么。此外,您不需要e.preventDefault,因为您捕获的不是“a”单击,而是“li”。。
<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>
file:///C:/Users/xxx/Desktop/stackoverflow/index.html