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

  • SEARCH
  • Home
  • 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 1063517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:47:39+00:00 2026-05-16T18:47:39+00:00

If I have 4 tabs where the first 2 are loaded with ajax and

  • 0

If I have 4 tabs where the first 2 are loaded with ajax and the last 2 are static, how do I pre-load the 2 ajax tabs by default?

For the moment, only the first tab is automatically loaded, the second one is loaded when clicked. I want them both to be loaded so that when I click the second one, the content is already loaded. I tried to call the load event on the second tab like this:

$(document).ready(function () {
    $("#main-tabs").tabs({
        cache: true
    });

    $("#main-tabs").tabs("load", 1);
});

And this loads the second tab, but for some strange reason, the first one doesn’t load at all; not even when I click a different tab and click back on the first one, it will not load.

Then I tried something like this:

$(document).ready(function () {
    $("#main-tabs").tabs({
        cache: true
    });

    $("#main-tabs").tabs("load", 0);
    $("#main-tabs").tabs("load", 1);
});

Same result, second tab is loaded, first one is not.

How can all of them (ajax ones) be loaded automatically?

  • 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-16T18:47:40+00:00Added an answer on May 16, 2026 at 6:47 pm

    Source of the problem

    Two facts:

    • When jQuery loads a tab with its load method, if another AJAX load request is in progress, this will be aborted (probably because if you select one tab and it loads by AJAX and then quickly select another to be loaded, jQuery assumes you don’t want to load both – just the last one).
    • When you set the first tab to be loaded by AJAX, .tabs("load",0) will be called by default to populate the first tab.

    Combining these two facts, you see what’s going on. load is being called first to populate the first tab, and then called again to populate the second one. The second load cancels out the first.

    Possible solution

    Since you can’t issue multiple loads on the same tab menu at the same time, we’ll have to find another way. This solution uses the load option of tabs to load each tab in sequence. In other words, when one load is finished, it starts loading the next one. When that one is finished, it loads the next one and so on.

    //the indexes to be loaded.
    //In your case it's only index 1 (index 0 is loaded automatically)
    var indexesToLoad = [1];
    
    var loadNextTab = function() {
        if (indexesToLoad.length == 0) return;
        var index = indexesToLoad.shift();
        $("#main-tabs").tabs("load",index);
    };
    
    $("#main-tabs").tabs({
        cache: true,
        load: loadNextTab
    });
    

    Possible improvements to this method:

    • instead of specifying indexes to load, make it figure out itself what tabs are AJAX tabs and load them
    • make it so loadNextTab can be used on multiple tabbed menus at the same time
    • make it integratable (if that’s a word) with other load callback functions

    How did I find out what was wrong?

    By using firebug. It’s an addon for firefox. Firebug shows all AJAX requests in its console, and as the screenshot shows, it wasn’t that hard to figure out what was going on 🙂 I really recommend it. (There are similar tools for most major browsers – press ctrl+shift+j in chrome or F12 i IE.)

    Screenshot of Firebug console showing ajax requests

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tabs. I want load then on demand except first tab. If
I have a TabActivity with three tabs defined. The first tab is light-weight and
I have some tabs that are ajax powered. So everytime a tab is clicked
I have a page with 3 tabs on it. The first tab has a
I have a set of jQuery UI AJAX tabs that load individual .php pages
I have an app with several different tabs. The first of these tabs should
So I want to have tabs with default style but I want to handle
I have 3 tabs, created by js. Active tab has class named active and
I have a tabs as views in my activity. Each tab represents a ListView
I have three tabs. When I press the tab button on the bottom, is

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.