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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:02:53+00:00 2026-05-31T05:02:53+00:00

$(#classesLink).click(function(event) { $(#globalUserContent).children().slideUp(normal, function() { $.ajax({ type: POST, url: classes.php?token=+randString+, success: function (msg) {

  • 0
$("#classesLink").click(function(event) {
    $("#globalUserContent").children().slideUp("normal", function() {
        $.ajax({
            type: "POST",
            url: "classes.php?token="+randString+"",
            success: function (msg) {
                $("#globalUserContent").html(msg);
            },
            error: function (msg) {
                $("#globalUserContent").html(msg);
            }
        });            
    });
    return false;
});

I have the above code and when i click the .classesLink button and check the firebug requests, it shows that it is being submitted twice, is there anything wrong with it?

  • 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-31T05:02:54+00:00Added an answer on May 31, 2026 at 5:02 am

    As noted by @am not I am. $("#globalUserContent") has two childrens so the callback fires twice one for each child, use this:

    $("#classesLink").click(function(event) {
        $.when($("#globalUserContent").children().slideUp("normal"))
         .then(function() {
            $.ajax({
                type: "POST",
                url: "classes.php?token="+randString+"",
                success: function (msg) {
                    $("#globalUserContent").html(msg);
                },
                error: function (msg) {
                    $("#globalUserContent").html(msg);
                }
            });            
        });
        return false;
    });
    

    This will execute the callback- ajax requst, when the slideUp effect is finished, And doesn’t hardcode the setTimeout delay in the code.

    If you hardcode 600 in the code, the code could break if the "normal" duration will change some day, or someone changed the slideUp duration effect but didn’t change the timeout delay.

    But you can put the duration-delay in a variable so you change it in one place – @am not I am suggestion.

    when docs:

    Description: Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.

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

Sidebar

Related Questions

I am binding the click event to 4 href's (they have class=alink) using JQuery
If I have this html <ul class=link color>...</ul> and jQuery: $(.link li).click(function(){ //do stuff
I read this about Python classes ( link ) and it seems to be
I am calling a function test() on an anchor tag like this:- <a class=link
i have html code block like this <div id=some-div> <a href=# class=link-click>some link text</a>
Given the following HTML structure: <div id=wrapper> <div id=top> <a href=http://example.com class=link>click here</a> </div>
I have a code block looking something like this: <p class=cont> <a href=otherpage.php class=link><img
I'm running the PHP code below from command line. The issue is, its memory
I had this working to spec, until the specs changed. This function is now
I have the following code: <h1><a href=# class=link>Click here</a></h1> <div class=acitem></div> <div class=acitem2></div> <script>

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.