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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:44:31+00:00 2026-05-28T19:44:31+00:00

I have 2 different set of codes, the only difference is the location of

  • 0

I have 2 different set of codes, the only difference is the location of $(this).closest('.organizer_listing').slideUp('fast');. In the first set of code, it works, but I prefer for that line of code to be as in the 2nd set of code inside the callback function, which no longer works – slideUp does not seem to be executed.

Why is this so? How should I fix it?

Variation 1

$("input[type=checkbox]:checked").each(function() {
    $(this).closest('.organizer_listing').slideUp('fast');  // Remove listings visually from list
    // Send AJAX request to delete from database
    var listing_id = $(this).closest('.organizer_listing').data('listing_id');
    $.ajaxSetup({ cache: false });
    $.getJSON(base_url + 'organizer/delete_favorite',
        {listing_id: listing_id},
        function(json) {
            $.modal.close();
    });
});

Variation 2

$("input[type=checkbox]:checked").each(function() {
    // Send AJAX request to delete from database
    var listing_id = $(this).closest('.organizer_listing').data('listing_id');
    $.ajaxSetup({ cache: false });
    $.getJSON(base_url + 'organizer/delete_favorite',
        {listing_id: listing_id},
        function(json) {
            $.modal.close();
            $(this).closest('.organizer_listing').slideUp('fast');  // Remove listings visually from list
    });
});
  • 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-28T19:44:32+00:00Added an answer on May 28, 2026 at 7:44 pm

    Variation two doesn’t work because in your $.getJSON callback, this is no longer the current element in your each loop, but rather the jqXHR object.

    You can easily work around this by saving the value of this to a new variable, which your callback will “close over” (have access to):

    var self = this;
    $.getJSON(base_url + 'organizer/delete_favorite',
            {listing_id: listing_id},
            function(json) {
                $.modal.close();
                $(self).closest('.organizer_listing').slideUp('fast');  // Remove listings visually from list
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code giving me the strange error message Uncaught TypeError: Cannot set
Is it possible to have a different set of dependencies in a maven pom.xml
I am adding musicCD information to a set. I have two different functions for
I have a set of different interfaces and I need to give them access
I have set up transactional replication between two SQL Servers on different ends of
We have developers working in different geographic locations and we want to set up
I have a webpage that implements a set of tabs each showing different content.
I have a table that has three different date columns, so I set each
I have different php output in jQuery-based tabs. This output is formed from database
I have different urls that points to the same code www.url1.com www.url2.com I need

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.