dongyan1625 2017-10-05 20:11
浏览 64
已采纳

在导航栏上用jquery加载php代码

This is my case : i'm trying to inject a php code into a div thanks to a navbar. But nothing changes. When i click on a link "li" it is supposed to load it's own php's page. For example if i click on "Print" it will show the "print.php"

Thank you for your help

<nav class="hidden-xs hidden-sm col-md-12 navbar navbar-inverse">

<div class="collapse navbar-collapse" id="filtre">
  <ul class="nav navbar-nav">
    <li class="index" id="index"><a href="index.php">Tous</a></li>
    <li class="print" id="print"><a href="print.php">Print</a></li>
    <li class="illustration" id="illustration"><a 
 href="illustration.php">Illustration</a></li>
    <li class="logotype" id="logotype"><a href="logotype.php">Logotype</a>
 </li>
    <li class="web" id="web"><a href="web.php">Web</a></li>
    <li class="photographie" id="photographie"><a 
href="photographie.php">Photographie</a></li>
  </ul>
</div>

</nav>
<script>
$('#filtre').on('click', 'li', function(e) {
  var item = e.target;

switch (item.id) {
case 'index':
   $('#index').load('index.php');
  break;
case 'print':
   $('#print').load('print.php');
  break;
 case 'illustration':
  $('#illustration').load('illustration.php');
  break;
case 'web':
  $('#web').load('web.php');
   break;
case 'photographie':
  $('#photographie').load('photographie.php');
  break;
  }
 });
 </script>
  • 写回答

4条回答 默认 最新

  • douqian3712 2017-10-08 09:30
    关注

    Thank you all for your reply. I did this code and works fine :

     <script>
          $(document).ready(function(){
           $('#filtre li').click(function(){
           $('#content-data').load('./'+$(this).attr("class")+'.php', function() {
             $('#content-data').fadeIn('slow') ;
         });
           return false;
         });
         })
      </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办