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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:58:54+00:00 2026-06-12T07:58:54+00:00

In the following code how would I use $(this).parents(‘#friendRequest’).remove(); in my ajax success callback

  • 0

In the following code how would I use $(this).parents('#friendRequest').remove(); in my ajax success callback function, and use $(this) to get selector of the click event in the first line?

jQuery(".notyAcceptFriendRequest").on('click', function() {
    notyId = jQuery(this).attr("notyIdOne"); // pull in the id of the current selected notification
    userProfilesUserId = $('#requestAlert').attr('userProfilesUserId'); // pull in the id of the current selected user profile id
    if (notyId == userProfilesUserId) { // if notification id is the same as the user profiles id, do the following
        $("#requestAlert").replaceWith('<span class="font1">You two are now friends</span>'); // the user profile friend requester will be replaced with the text
        $(this).parents('#friendRequest').remove(); // find the '#friendRequest' id from the parent elements and fade it out
    } else if (notyId != userProfilesUserId) {
        /* the below will execute when the user
         * clicks the 'Add' button and he/she is
         * not on the targeted users page
         */
        $.ajax({
            type: "POST",
            dataType: "JSON",
            url: "<?=base_url()?>index.php/reguserDash/acceptFriendNoty",
            data: {notyId: notyId},
            json: {friendshipCaneled: true},
            success: function(data) {
                if(data.acceptNotyFriendSuccess == true) {
                    $(this).parents('#friendRequest').remove();
                }
            }
        })
    }
});
  • 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-12T07:58:55+00:00Added an answer on June 12, 2026 at 7:58 am

    this in the callback is not the same as this in the handler.

    You need to store this in a local variable, then use that variable in the callback.

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

Sidebar

Related Questions

For the following code snippets why would I use one assignment vs another? thx
I'm using the following code successfully with HTTP but I would like to use
I would like to know if it is safe to use the following code
I am trying to get recursive data. Following code returns all parents on the
I'm curious if following code would be considered safe? using (SqlConnection cn = new
I would like to know if the following code would be a good pattern
In the following code I would like to hide Hello world but keep visible
Given the Following Code how Would i Change/Set my Silverlight WCF Service URI in
I am confused as to why the following code snippet would not exit when
I would expect the following code to throw a ParseException, but it is 2

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.