我正在使用JQuery UI创建一个选项卡,并且我想将我的php文件的内容输入到该选项卡中.我首先创建一个选项卡,然后选择它.
I'm using JQuery UI to create a tab, and I want to the contents of my php file to be entered into this tab. I start by creating a tab, and then selecting it.
function createTab2() { //create a tab $("#tabs").tabs("add","#tabs-2","Second Tab"); $("#tabs-2").css("display","block"); $('#tabs').tabs('select', "#tabs-2"); $.get('tab2.php', function(data) { $('.result').html(data); alert('Load was performed.'); }); }我尝试使用JQuery .get函数返回数据,并且在出现警报时它可以正常工作.但是,内容没有输入到选项卡中-我只是在Javascript控制台中看到了它们.
I tried using the JQuery .get function to return the data and it works fine as an alert appears. However, the contents are not entered into the tab - I just see them listed in my Javascript console.
如何使php文件的内容显示在此标签中?
How can I make the contents of the php file appear in this tab?
推荐答案在标签2的标记中,您需要在源html中添加href.
In your markup for tab 2 you need add an href to the source html.
<div id="tabs"> <ul> <li><a ><span>Content 1</span></a></li> <li><a href="tab2.php"><span id="tabs-2">Content 2</span></a></li> <li><a ><span>Content 3</span></a></li> </ul> </div>或者您可以尝试直接加载标签.
or you can try load the tab directly.
$("#tabs-2").load('tab2.php');源
更多推荐
jQuery UI并将数据加载到选项卡中
发布评论