Ticket #6424 (closed bug: invalid)
.load callback function bug
| Reported by: | misssprite | Owned by: | |
|---|---|---|---|
| Priority: | Milestone: | 1.4.3 | |
| Component: | ajax | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I wrote : $('#adiv').load('url.html',function(){
alert($('#aspan').text()); aspan is a span elem in the url.html
}); finally i found i can't select any element in the url.html in the callback function so i had to use $.ajax, and the $('#adiv').html(...) function. it seems a bug with jquery the document tree hasn't been constructed when the callback func is called
Change History
comment:1 Changed 3 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
comment:2 follow-up: ↓ 3 Changed 3 years ago by misssprite
sorry, i made a mistake in the example above. I indeed loaded a html fragment so it is: $('#adiv').load('url.html #anotherdiv',function(){ ...
Strangely, I tried a bare test, leaving only the neccessary elements and it worked! But it doesN'T worked in my real html :( , while the $.ajax and $('#adiv').html(...) way works well
I'm really confused. Probably it's not a bug...
comment:3 in reply to: ↑ 2 Changed 3 years ago by misssprite
the WORKING example did NOT working after i copy it to my tomcat space and access through tomcat Jesus! Replying to misssprite:
sorry, i made a mistake in the example above. I indeed loaded a html fragment so it is: $('#adiv').load('url.html #anotherdiv',function(){ ...
Strangely, I tried a bare test, leaving only the neccessary elements and it worked! But it doesN'T worked in my real html :( , while the $.ajax and $('#adiv').html(...) way works well
I'm really confused. Probably it's not a bug...
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I am guessing that you may be trying to load an entire html document from url.html, rather than just an html fragment. If that isn't the case, please reopen with a test case. The forum is also a good place to ask questions about suspected bugs before filing a ticket, http://forum.jquery.com .