Bug Tracker

Modify

Ticket #7624 (closed bug: invalid)

Opened 3 years ago

Last modified 12 months ago

a.ownerDocument is undefined

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

Description (last modified by rwaldron) (diff)

$('.delete').live('click', function()
{
	var id = $(this).parent().attr('data-id');
	
	$.ajax({
		url: 'include/post.php',
		type: 'POST',
		data: 'delete=' + id,
		success: function(data)
		{
			if(data == 'deleted')
			{
				$(this).slideUp('slow');
			}
		}
	});
});

Returns an error in FireBug:

a.ownerDocument is undefined (line 129)

Which stances to this line:

d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left;

Change History

comment:1 Changed 3 years ago by rwaldron

  • Owner set to anonymous
  • Status changed from new to pending
  • Description modified (diff)

Please provide a reduced test case on  http://jsfiddle.net

comment:2 Changed 3 years ago by jitter

  • Status changed from pending to closed
  • Resolution set to invalid

this inside an ajax callback is a reference to the ajax settings object. As the documentation states

The beforeSend, error, dataFilter, success and complete options all take callback functions that are invoked at the appropriate times. The this object for all of them will be the object in the context property passed to $.ajax in the settings

Maybe you intended on using the  context option so that this refers to a DOM element not to a plain js object.

contextObject: This object will be made the context of all Ajax-related callbacks. For example specifying a DOM element as the context will make that the context for the complete callback of a request

Last edited 3 years ago by jitter (previous) (diff)

comment:3 Changed 2 years ago by anonymous

for anyone else that finds this page, you need to put your code in a .each _

comment:4 Changed 2 years ago by fco.pacheco@…

The error is in the function "success": You have to write the id of the element, because when you use "this" you're not referencing $('.delete').

comment:5 Changed 2 years ago by anonymous

I received this error message while running a function inside a setTimeout() with "this" as the parameter; setTimeout('UpdateHeight(this);',1000);

Obviously "this" is not available in that scope, so when jquery tried to access it within the function it errored.

comment:6 Changed 12 months ago by anonymous

I received it while trying to pas 'this' in an anonymous function within a setInterval. Obviously I should have pased $(this) instead.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.