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 673043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:33:05+00:00 2026-05-14T00:33:05+00:00

I have different php output in jQuery-based tabs. This output is formed from database

  • 0

I have different php output in jQuery-based tabs. This output is formed from database and it consists of several <div>‘s. Every time I click any tab it sends AJAX request to the php script which performs “SELECT” request and gives result back as response to AJAX request from the tab.

$(document).ready(function() {

    $('ul.tabs li').css('cursor', 'pointer');

    $('ul.tabs.tabs1 li').click(function(){
        var thisClass = this.className.slice(0,2);
        $('div.t1').hide();
        $('div.t2').hide();
        $('div.t3').hide();
        $('div.t4').hide();
        $('div.' + thisClass).show('fast');
        $('ul.tabs.tabs1 li').removeClass('tab-current');
        $(this).addClass('tab-current');
        var data = thisClass;

        $.ajax({
            type:"GET",
            url:"handler.php?name="+data,
            data:data,
            success:function(html) { 
            $('div.' + thisClass).html(html); 
            }
        });
      return false;
    });
});

//Server-side PHP script:

<?php

$name = $_GET[name];
switch ($name) {
    case "t1":
    query_and_output_1();

    case "t2":
    query_and_output_2();

    // etc...
}
?>

The problem is that the first tab contains output that must be in second and third ones as well, the second also contains the third tab output.

Sorry for such a rubbishy question, I used to work with server side and unfortunately I’m not familiar with DOM and jQuery yet.

Thanks.

  • 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-14T00:33:06+00:00Added an answer on May 14, 2026 at 12:33 am

    The problem is not in your jQuery but in your PHP code ..

    you need to break after each case in the switch code. Otherwise all subsequent cases get executed..

    so

    switch ($name) {
        case "t1":
        query_and_output_1();
        break;
    
        case "t2":
        query_and_output_2();
        break;
    

    is the correct way ..
    reference: http://php.net/manual/en/control-structures.switch.php

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

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Fixed a while ago. The <asp:CalendarExtender tag was incorrect, needed… May 16, 2026 at 11:24 am
  • Editorial Team
    Editorial Team added an answer You can use Webclient's UploadValues() or UploadString(). May 16, 2026 at 11:24 am
  • Editorial Team
    Editorial Team added an answer I assume you mean dynamically? You won't be able to… May 16, 2026 at 11:24 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm looking for some help converting this from prototype to jQuery. I'm doing some
PHP: Output multiple line command-line outputs as different lines. Sorry if the title is
In a lot of my PHP classes, I have this code: private $strError =
Hey I am very new to Web Programming. I have been learning PHP from
This is a Continuation of Jeditable: how to set parameters based on dom element
I have a Zend Framework application that is making use of jQuery UI. In
I have two XML sources to retrieve data from. I want to use them
I realize there have been a few other questions on this topic, and the
I have to write a script which will be hosted on differents domains. This
I have a partly inherited web application in PHP and after poking around with

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.