2012-07-07 22 views
0

代碼不顯示我的PHP元素,我想知道爲什麼。用AJAX顯示單獨的PHP文檔

這裏是我使用的HTML:

<div class="tablocation"> 

    <ul class="css-tabs"> 
     <li><a class="current" href="/wp-content/themes/blue-and-grey/uni-general.php">General</a></li> 
     <li><a href="/wp-content/themes/blue-and-grey/uni-courses.htm">Courses</a></li> 
     <li><a href="/wp-content/themes/blue-and-grey/uni-inthearea.htm">In the area</a></li> 
     <li><a href="/wp-content/themes/blue-and-grey/uni-sportsandfacilities.htm">Sports & facilities</a></li> 
    </ul> 

    <div class="clear"></div> 

    <div class="css-panes"> 
     <div style="display:block"></div> 
    </div> 

就拿首先,對於單general.php - 這將不加載,但其他文件爲的.htm會加載。只要它是一個PHP文檔,它就不會。

另外 - 下面是我用來加載文檔的腳本。

<script> 
    $(function() { 
     $("ul.css-tabs").tabs("div.css-panes > div", { 
     effect: 'ajax', 
     onBeforeClick: function(event, i) { 
     // get the pane to be opened 
     var pane = this.getPanes().eq(i); 

      // only load once. remove the if (...){ } clause if 
      // you want the page to be loaded every time 
     if (pane.is(":empty")) { 
      // load it with a page specified in the tab's href 
      // attribute 
      pane.load(this.getTabs().eq(i).attr("href")); 
     } 
     } 
    }); 
    }); 
</script> 

我可以提供PHP文件,如果需要但要公平我不認爲這是問題所在。

+0

哪些選項卡是您使用 – 2012-07-07 12:11:53

+0

「將不會加載」 插件 - 在JavaScript控制檯中的任何錯誤?空的內容? 404? – JJJ 2012-07-07 12:11:54

+0

我沒有空的內容,它是:http://www.jquerytools.org/demos/tabs/ajax-history.html#ajax1.htm – 2012-07-07 12:29:01

回答

0

從標準插件功能看起來不太自定義。

只加載標籤頁$("ul.css-tabs").tabs();

使用jQuery UI,不管你有href將通過AJAX加載的標籤。

*Fetch external content via Ajax for the tabs by setting an href value in the tab links.*

http://jqueryui.com/demos/tabs/#ajax

+0

我試過了,它會很高興地加載內容時,它是一個HTM文件 - 只是不是一個PHP文件,只是加載我的標籤顯示然後im即不同的頁面。這不是我以後.. – 2012-07-07 12:27:02

+0

任何想法是爲什麼它不工作? – 2012-07-07 13:47:21

+0

在我的答案中初始化插件準系統,看它是否有效。 – 2012-07-07 20:20:26