Skip to main content

Bug Tracker

Side navigation

#7624 closed bug (invalid)

Opened November 24, 2010 05:34PM UTC

Closed November 24, 2010 06:18PM UTC

Last modified February 26, 2014 05:46AM UTC

a.ownerDocument is undefined

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description
$('.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;
Attachments (0)
Change History (7)

Changed November 24, 2010 05:36PM UTC by rwaldron comment:1

description: \ {{{ \ $('.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; \ }}} \ \ {{{ \ $('.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; \ }}} \ \
owner: → anonymous
status: newpending

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

Changed November 24, 2010 06:18PM UTC by jitter comment:2

_comment0: `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 [http://api.jquery.com/jQuery.ajax/ `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 request1290622747906071
resolution: → invalid
status: pendingclosed

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

Changed November 26, 2010 11:13AM UTC by anonymous comment:3

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

Changed March 18, 2011 03:49PM UTC by fco.pacheco@gmail.com comment:4

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').

Changed June 16, 2011 10:47AM UTC by anonymous comment:5

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.

Changed June 14, 2012 09:08AM UTC by anonymous comment:6

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

Changed February 26, 2014 05:46AM UTC by anonymous comment:7

Replying to [comment:3 anonymous]:

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

Thank you so much! This just saved a lot of headache.