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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:11:51+00:00 2026-06-13T02:11:51+00:00

I have a .load() function that I need to convert to .ajax(). I initially

  • 0

I have a .load() function that I need to convert to .ajax(). I initially used .load() because of its ease of use but now I see that in order to achieve my desired result, I must use .ajax().
Here is my .load() function:

$("#rightframe").click(function(){
    $("#screen").load("form.html #contact");
  });

I want to convert that to .ajax() and add the following piece of code to set a minimum time an .ajax() call would take (this is because I have a loading GIF that looks weird if it doesn’t run long enough)

So I found this piece of code when trying to figure out how I can set a minimum length of time the loading GIF would take.

var counter = 2;
function decrement() {
  if (--counter == 0) {
    $('#loader').hide();
  }
}
setTimeout(decrement, 1000);
$.ajax(..., complete: decrement);

Does anyone know how to alter the .load() function to .ajax() and add the decrement function to the .ajax() function?

Thank you,

Katie

  • 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-13T02:11:52+00:00Added an answer on June 13, 2026 at 2:11 am

    I think you’d want something like this:

    $("#rightframe").click(function () {
        $("#loader").show();
        setTimeout(function () {
            $.ajax({
                url: "form.html",
                complete: function () {
                    $("#loader").hide();
                },
                success: function (data) {
                    $("#screen").empty().append($(data).find("#contact"));
                },
                error: function () {
                    // Handle an error occurring
                }
            });
        }, 2000);
    });
    

    I’m not sure why you are using/need the decrement function, but something like this code should take care of the loading image being shown long enough.

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

Sidebar

Related Questions

I have a simple c function that I need to convert to MIPS instructions
I have a deferred function that binds a mouseenter event: $(window).load(function(e) { var $container
I have a data-upload function that load some data into several tables and processes
I have a java script function that i have called on body load mousemove()
I have a large function that I wish to load only when it is
I have this class that have a function to load other classes and create
I have site which uses $(selector).load(path) function in more than 300 pages. Now my
I have load balanced web servers My application has a function that allows the
I have developed a Wordpress site that loads pages dynamically using the .load function.
i have a button1_click() function which runs on page load,,now i want to call

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.