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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:34:20+00:00 2026-05-25T12:34:20+00:00

I ran into a very vague error while doing some simple jQuery DOM manipulation.

  • 0

I ran into a very vague error while doing some simple jQuery DOM manipulation.

The line that triggered the error is the following:

$(this).closest('tr').remove();

The error, as stated in the title, is:

Uncaught TypeError: Cannot call method ‘toLowerCase’ of undefined

in file: jquery-1.6.2.js.

I have already tried with jQuery 1.6.3 and jQuery 1.5.1, but nothing changed. I still keep getting the error.

The line above is bound to a button which, when clicked, submits an AJAX POST request, then when successful, it removes its own <tr>. I have already tried another way by doing:

$(this).parent().parent().remove() but to my surprise, this did nothing.

I’m using Chrome, in case it matters, but I get the same error in FF.

EDIT:

This is my code:

$(".remove").live('click', function(e)  {
    var str = $(this).attr('id').match(/\[(.*?)\]\[(.*?)\]/);
    var type = str[1];
    var id = str[2];

            // IF I PUT THE remove() HERE, IT WORKS.

    $.ajax({
        type: 'POST',
        url: '/admin/ajax_remove_event_detail',
        data: {type: type, id: id},
        success:function(res)   {
            if(res)
            {
                $(this).closest('tr').remove();
                // this gives me an error
            }
            else
            {
              // error handling 
            }
        }
    });

    e.preventDefault();
});

If I put the remove() outside of the if somewhere, it works. Why won’t it work when it’s inside the ajax call/if? Makes no sense to me? 🙁

Any help here? Thanks in advance.

  • 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-25T12:34:21+00:00Added an answer on May 25, 2026 at 12:34 pm

    I don’t know what you expect the value of this to be in your “success” handler, but I bet it’s not what you think. Save this outside the “$.ajax()” call:

    var clicked = this;
    $.ajax(
      // ...
      success: function(res) {
        if (res) {
          $(clicked).closest('tr').remove();
        }
        else {
          // ...
        }
      }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into an interesting (and very frustrating) issue with the equals() method today
I ran into a scenario where LINQ to SQL acts very strangely. I would
I ran into the problem that my primary key sequence is not in sync
I ran into an interesting behavior recently. It seems that if I override .equals()
I ran into an issue with something that I am probably just overlooking. I
I've ran into a problem while trying to test following IRepository based on NHibernate:
Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's
I recently ran into a very sneaky bug, in which I forget to dereference
Recently I ran into a very strange issue: touching the screen of the iPhone
Today I ran into a very difficult TDD problem. I need to interact with

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.