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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:07:26+00:00 2026-05-20T05:07:26+00:00

I have a web page with 2 tabs. These tabs show/hide divs when clicked.

  • 0

I have a web page with 2 tabs. These tabs show/hide divs when clicked. Both tabs use jquery to make an ajax call to a php script to display results from a different database. So tab 1 shows a list of food and the second tab shows a list of prices. Its set to refresh automatically every 30 seconds. My question is when I click between the 2 tabs I prefer the tab not clicked stops the ajax call so only the one ajax call is running, basically for optimization purposes. How would I go about doing this? Would I use setInterval to have it run the first tab ajax call every 30 seconds then when the other tab is clicked a function is called to run clearInterval on the id the first setinterval was running? Then visa versa if the first tab is clicked it clears the interval for the second tab ajax call?

  • 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-20T05:07:27+00:00Added an answer on May 20, 2026 at 5:07 am

    Basicly there is no reason for what you are doing.

    I would prefer, if you have something to load, that needs to be loaded after some time, you should call for both tabs, but only ask, if something changed. So let´s say, you call the server every 10 seconds if something changed, returning false or true is not such a huge thing, and if returned yes, just synchronize both items.

    if there is no need to sync both items, why you just dont sync them when the tab is clicked?

    For user experience it´s better to ask for changes often, but syncing the content only if needed.

    And if you do this all, don´t use setInterval but setTimeout and in you function call the setTimeout again, setInterval is not so good 😉

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

Sidebar

Related Questions

I have a web page consisting a JQuery UI Tabs widget. Tab widget loads
I currently have a web page that has 2 tabs on it. The 2
In my web page a have a div where I put some tabs. The
I have a simple web page that has 3 tabs in my main content
i have a web page that i want to load dynamically (ajax) into a
I have a simple web page with 5 tabs. Each tab is a LinkButton
I have web page in PHP which displays all records in a table. I
I have web page which is passing a querystring parameter to page 2: <a
I have a web page that includes a bunch of images. Sometimes the image
I have a web page which contains a select box. When I open a

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.