[英]Load a PHP file in in a tab/div in HTML
I have a HTML file with 3 tabs.我有一个带有 3 个选项卡的 HTML 文件。 I want to load a PHP file when the user clicks on one specific tab (Tab1) out of 3 tabs.
当用户单击 3 个选项卡中的一个特定选项卡 (Tab1)时,我想加载一个PHP文件。
Tabs Code:标签代码:
<div id="content">
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" id="main_tab_content">
<li role="presentation" class="active"><a role="tab" data-toggle="tab" aria-controls="home" href="#home">Home</a></li>
<li role="presentation"><a role="tab" data-toggle="tab" aria-controls="tab1" href="#tab1">Tab 1</a></li>
<li role="presentation"><a role="tab" data-toggle="tab" aria-controls="tab2" href="#tab2">Tab 2</a></li>
</ul>
Tab1 Code: Tab1代码:
<div class="tab-content">
<div role="tabpanel" class="tab-pane" id="tab1">
<div class="panel panel-default">
<div class="panel-body">Yet to be integrated.
</div>
</div>
</div>
and so on for Home and Tab 2 .等等Home 和 Tab 2 。
jquery load code: jquery 加载代码:
<script>
$( ".tab1" ).load( "/test/index.php" );
</script>
The code was written by a colleague, I am trying to use the same html layout to load my PHP file.该代码是由一位同事编写的,我正在尝试使用相同的 html 布局来加载我的 PHP 文件。 So far tried with with jquery load and i think issue i am facing is cz of the div class/id am using in load.
到目前为止尝试使用 jquery 负载,我认为我面临的问题是负载中使用的 div 类/id 的 cz。
Any inputs will be useful.任何输入都会有用。
Thanks in advance.提前致谢。
<script> $(document).ready(function(){ $('.tab_1').click(function(){ $.get( "/test/index.php", function( data ) { $( ". tab_1" ).html( data ); }); }) }) </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.