Tabs with Ajax/PHP

I’d like to make a sidebar-like content area on my Wordpress site that has two tabs:

The main tab, which will be displayed by default, will consist of several popular articles from the site.

The secondary tab, will display some other posts.

The sidebar loads on every page except landing pages.

It’s obviously not very efficient to have the “secondary” tab content loaded on every page, since it will only get used a small percentage of the time.

So, I think what I should do is use ajax to load the “secondary tab” content.

1: Is this the best way to do this?

2: What would that look like, code wise? Do I just use the “secondary tab” button to XMLHttpRequest a document called seconary-content.php?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.