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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:36:50+00:00 2026-06-07T04:36:50+00:00

I am currently working on a html5 and jquery project. I have an html5

  • 0

I am currently working on a html5 and jquery project. I have an html5 tab view on a page which keeps refreshing every 5 seconds. It refreshes by posting to a php script which retrieves information from the database and then some javascript adds the print out from the php script to a div. Before the refresh it updates another div with an ajax loading image, and once the update is complete it clears the div with  . Because of the refresh though it always defaults to the first tab, obviously, but I need to keep it on the selected tab after the refresh.

Below is the code for the tab selection.

function getEmailData()
{
    echo '
        <article class="tabs">
            <section id="tab1">
                <h2><a href="#tab1">Queued</a></h2>
                    <center><strong>Queued Emails</strong></center>
                ' . getEmails("Queued") . '
            </section>
            <section id="tab2">
                <h2><a href="#tab2">Trying</a></h2>
                <center><strong>Trying</strong></center>
                ' . getEmails("Trying") . '
            </section>
            <section id="tab3">
                <h2><a href="#tab3">Sent</a></h2>
                <center><strong>Sent Emails</strong></center>
                ' . getEmails("Sent") . '
            </section>
            <section id="tab4">
                <h2><a href="#tab4">Failed</a></h2>
                <center><strong>Failed Emails</strong></center>
                ' . getEmails("Failed") . '
            </section>
        </article>
    ';
} 

getEmails(); function returns the data should be displayed within each tab.

Below is the CSS

article.tabs
{
    position: relative;
    display: block;
    width: 40em;
    height: 15em;
    margin: 2em auto;
}

article.tabs section
{
    position: absolute;
    display: block;
    /*top: 1.8em;*/
    top: -10px;
    left: 0;
    height: 12em;
    padding: 10px 20px;
    background-color: #ddd;
    border-radius: 5px;
    box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
    z-index: 0;
    width: 800px;
    height: 300px;
}

article.tabs section:first-child
{
    z-index: 1;
        color: #333;
    background-color: #fff;
    z-index: 2;
}

article.tabs section h2
{
    position: absolute;
    font-size: 1em;
    font-weight: normal;
    width: 120px;
    height: 1.8em;
    top: -1.8em;
    left: 10px;
    padding: 0;
    margin: 0;
    color: #999;
    background-color: #ddd;
    border-radius: 5px 5px 0 0;
}


article.tabs section:nth-child(2) h2
{
    left: 132px;
}

article.tabs section:nth-child(3) h2
{
    left: 254px;
}

article.tabs section:nth-child(4) h2
{
    left: 376px;
}


article.tabs section h2 a
{
    display: block;
    width: 100%;
    line-height: 1.8em;
    text-align: center;
    text-decoration: none;
    color: inherit;
    outline: 0 none;
}

article.tabs section:target, article.tabs section:target h2
{
    color: #333;
    background-color: #fff;
    z-index: 2;
}

article.tabs section, article.tabs section h2
{
    -webkit-transition: all 500ms ease;
    -moz-transition: all 500ms ease;
    -ms-transition: all 500ms ease;
    -o-transition: all 500ms ease;
    transition: all 500ms ease;
}

Basically, my question is if I select the 3rd tab, and the ajax post does a reload, how do I make sure that the 3rd tab is still selected and doesn’t default back to the first.

Thanks for any help you can provide.

  • 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-06-07T04:36:53+00:00Added an answer on June 7, 2026 at 4:36 am

    As far as I see it, you have 3 options:

    1. refresh each tab individually and only refresh the contents of the tab, not the entire article
    2. Save the previously selected tab into a JavaScript variable before the Ajax call and then re-select the tab after the data is received and inserted
    3. Send the pre-selected tab through the ajax call and insert a ‘selected’ class on the tab in the back end code.

    2 and 3 are effectively the same – just changing where the data is stored.

    My preference would be number 1 as it does not require the jQuery to refresh the tab object and also reduces the amount of data posted back. If you must refresh the entire article, though, 2 or 3 would do (2 is probably easier to implement though!)

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

Sidebar

Related Questions

I am working on Project where I have JQuery 1-Page Horizontal scrolling website using
I'm currently working on a JavaScript project that uses the HTML5 canvas as a
currently I have a section of my page with jquery tabs. The tabs reference
I'm currently working on a project with the framework CodeIgniter. I use jQuery 1.7.1
I am currently working on a GWT project where I am displaying an HTML
Currently working for the first time with JSON and with little experience of jQuery.
I'm currently working on a JQuery game (Just to get around with using JQuery)
I'm currently working on a project where some bugs are popping up in our
Im currently working on a project for a time keeping system where the employee
I'm currently working on a project where we previously used Django. However this proved

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.