重新加载一个PHP include或require [英] reload a PHP include or require

查看:86
本文介绍了重新加载一个PHP include或require的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQuery选项卡,并且希望能够在单击时加载每个页面.

I am using JQuery tabs and i want to be able to load each page as it is clicked on.

所以我的index.php在数据库连接等的顶部都有一个include,然后我有以下选项卡:

so my index.php has an include at the top for my database connections etc, i then have these tabs:

<ul class="nav nav-tabs">
                  <li class="active"><a href="#tab_1" data-toggle="tab">Tab 1</a></li>
                  <li><a href="#tab_2" data-toggle="tab">Tab 2</a></li>
                  <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                      Dropdown <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu">
                      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
                      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
                      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
                      <li role="presentation" class="divider"></li>
                      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
                    </ul>
                  </li>
                  <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
                </ul>

,每个标签都有自己的内容div:

and each tab has its own content div:

<div class="tab-content">
                  <div class="tab-pane active" id="tab_1">

                  </div><!-- /.tab-pane -->
                  <div class="tab-pane" id="tab_2">

                  </div><!-- /.tab-pane -->
                </div><!-- /.tab-content -->

然后我有一些单独的页面,这些页面不包含我要包含在选项卡内容div中的数据库连接

Then i have individual pages that do not include the database connection which i want to include in the tab content divs

但是当index.php页面加载时,我不想让它们全部加载.单击选项卡时,如何设置每个包含要加载的内容?

but i dont want to have them all load when the index.php page loads. how can i set each include to load when the tab is clicked?

推荐答案

您可以使用jquery的加载功能.并且您可以在选项卡中包含php文件onclick.使用以下代码

You can use load function of jquery. And you can include php file onclick of your tab. Use below code

<script>
$(document).ready(function(){
$("#tabid").click(function()
{
    $("#whereToPlace").load("http://path/to/file");
});
});
</script>

别忘了先包含Jquery库

Don't forget to include Jquery library first

这篇关于重新加载一个PHP include或require的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆