Opened 14 years ago
Closed 13 years ago
#4235 closed bug (fixed)
$('#id).load() doesn't execute callback if selector matches an empty set
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | ajax | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Discovered this due to a typo in my code. Consider
$('#id).load('stuff.html', {}, callback);
If there is no element named 'id' on the page, load -does- run, and firebug does assure me that stuff.html is requested
Change History (3)
comment:1 Changed 14 years ago by
comment:2 Changed 13 years ago by
Component: | unfilled → ajax |
---|
The OP didn't reply, but I think the only issue here is whether the ajax should happen if no elements are selected, but never call the callback. We should document it either way.
comment:3 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
That's understandable, since the docs for .load say the callback is called this way:
If there are no elements in the jQuery object, the function can't be called because the
this
can't be given a value!So are you requesting that if no elements are selected the ajax shouldn't happen at all? Or some other behavior?