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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:17:08+00:00 2026-06-09T04:17:08+00:00

I have the following Jquery which, on clicking on a Checkbox, re-loads a DIV

  • 0

I have the following Jquery which, on clicking on a Checkbox, re-loads a DIV passing the value of the box and showing new items based on a query.

I would like to have a “Loading” bar for 3 seconds or so… before loading the content of the DIV, fading out after. And then load the DIV with a fade-in effect. I tried a few things but did’t work.

Here is my code.

Thanks!

jQuery(document).ready(function($) {
    $("input:checkbox").change(function() {
        if ($(this).is(':checked')) 
        {
            $(".loadingItems").delay(3000).fadeOut(3000);
            var color = [];
            color.push($(this).val());
            $(".indexMain").load('indexMain.php?color='+color);
        }
        else if ($(this).not(':checked')) 
        {
            $(".indexMain").load('indexMain.php');
        }
    });
});
  • 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-09T04:17:09+00:00Added an answer on June 9, 2026 at 4:17 am

    It’s normally considered bad practice to have your users wait for three seconds just so you can show off your loading bar, and by the time it’s faded out, six seconds have passed and your users have left. Remove the loading bar after the ajax call is finished and the content is ready. Also, are you sure you should be using an array in a querystring ?

    $(function() {
        $("input:checkbox").on('change', function() {
            $(".loadingItems").fadeIn(300); //fade in on change
            if (this.checked) {
                var color = [];
                color.push(this.value); //array in querystring ?
                $(".indexMain").load('indexMain.php?color='+color, function() {
                    $(".loadingItems").fadeOut(300); //remove when load is complete
                });
            }else{
                $(".indexMain").load('indexMain.php', function() {
                    $(".loadingItems").fadeOut(300);  //remove when load is complete
                });
            }
        });
    });
    

    I’ll take a wild guess and say this is what you’re after :

    $(function() {
        $("input:checkbox").on('change', function() {
            $(".loadingItems").fadeIn(300); //fade in on change
            var qs = this.checked ? 'color='+this.value : '';
            $(".indexMain").load('indexMain.php'+qs, function() {
                $(".loadingItems").fadeOut(300); //remove when load is complete
            });
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery code which runs when I'm clicking an option in
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I have the following jQuery which I want to output a list of images.
I have the following jquery code which doesn't work quite right when trying to
I have the following jQuery code: $(body.page-calendar-practices-2012-05 #content-header h1#title) which works fine. I can
Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
I have the following ListView in which I am using the JQuery UI sortable
I have the following JavaScript code which I like to convert to jQuery but
I have the following code alternatives, neither of which is satisfactory. I'm using jQuery
I have HTML which includes scripts in following order <script src=../static/js/jquery.js type=text/javascript> <script src=../static/js/bootstrap.js

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.