Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6786409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:14:30+00:00 2026-05-26T17:14:30+00:00

Here is my problem: The Problem I have created Tabs using jQuery which is

  • 0

Here is my problem:

The Problem

I have created Tabs using jQuery which is very similar to that of jQueryUI or Twitter Bootstraps’s Tabs. There are 3 Tabs on page: “Today”, “This Week”, “This Month”. When you click on “Today” tab, you’ll see all the posts submitted today. And other 2 tabs work similarly. It’s working, all the data loads but I don’t want the users to wait for the data to take so much time to load. (If there are 10 posts under each tab, then the page is loading 30 posts), to save their time, I want to use jQuery AJAX to fetch the posts when a specific tab is active, or in simple words, when a user clicks on the tab, the posts should load using AJAX.

What I am Thinking

Yes, I know I can create 3 different pages for that, but how should I load the data using AJAX when the Tab is clicked? Here is my HTML (with javascript) Code:

<script type="text/javascript">

$(document).ready(function() {

    //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });

});

</script>

<ul class="tabs">
    <li><a href="#today">Today</a></li>
    <li><a href="#week">This Week</a></li>
    <li><a href="#month">This Month</a></li>
</ul>

<div class="tab_container">

<div id="today" class="tab_content">
       <!--Load the Content from today.php-->
</div>

<div id="week" class="tab_content">
       <!--Load the Content from week.php-->
</div>

<div id="month" class="tab_content">
       <!--Load the Content from month.php-->
</div>

</div>

More Info

  • Please include the code for better understanding as I have just started learning AJAX.
  • I am using PHP and MySQL.
  • The data should be sent using POST method.
  • Try to use jQuery AJAX, please.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:14:30+00:00Added an answer on May 26, 2026 at 5:14 pm

    It seems to me the following modification would work for you. In this scenario, jQuery POSTs to some URL you choose if the active tab’s content is empty, and then retrieves whatever HTML comes down from the server a drops it inside the active tab asynchronously.

    You’ll need to change some of the parameters inside the $.ajax call, but other than that – it should work.

    <script type="text/javascript">
    
    $(document).ready(function() {
    
        //When page loads...
        $(".tab_content").hide(); //Hide all content
        $("ul.tabs li:first").addClass("active").show(); //Activate first tab
        $(".tab_content:first").show(); //Show first tab content
    
        //On Click Event
        $("ul.tabs li").click(function() {
    
            $("ul.tabs li").removeClass("active"); //Remove any "active" class
            $(this).addClass("active"); //Add "active" class to selected tab
            $(".tab_content").hide(); //Hide all tab content
    
            var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
    
            if($(activeTab).html() == '') {
              $.ajax({
                url: '/url/to/post',
                type: 'post',
                dataType: 'html',
                success: function(content) {
                  $(activeTab).html(content);
                }
              });
            }
    
            $(activeTab).fadeIn(); //Fade in the active ID content
            return false;
        });
    
    });
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this jQuery ajax navigation tabs plugin that I created using some help
Here's the problem. In my app, I have 5 tabs which contains activities. In
I'm creating a web application which loads tabs using AJAX. My problem is that
I have group of jQuery Tabs that are created dynamically. Each tab has an
Here is my problem. I have created a pretty heavy readonly class making many
Here's my problem: I have do create a menu/list of actions (which would be
Here's my problem: I have a virtual method defined in a .h file that
Here's the problem: I have couple of pages which gets its content from a
Here's my problem: I've have an application with tabs. in each tab I have
I have created some rounded navigation tabs using CSS and am having trouble when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.