#7624 closed bug (invalid)
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 (last modified by )
$('.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 (7)
comment:1 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Owner: | set to anonymous |
Status: | new → pending |
comment:2 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
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
comment:3 follow-up: 7 Changed 12 years ago by
for anyone else that finds this page, you need to put your code in a .each _
comment:4 Changed 12 years ago by
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 12 years ago by
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 11 years ago by
I received it while trying to pas 'this' in an anonymous function within a setInterval. Obviously I should have pased $(this) instead.
comment:7 Changed 9 years ago by
Replying to 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.
Please provide a reduced test case on http://jsfiddle.net