Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Can't use jQuery to interact with returned ajax html
Old 06-18-2009, 07:00 AM Can't use jQuery to interact with returned ajax html
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
Hi everyone,

I'm using jQuery to retrieve some info using the GET ajax request. It displays the information as html e.g. the returned info displays a table. My problem is that any jQuery code relating to that table doesn't work.

I.e. my <div class="target"></div> is empty. The user clicks a button and it returns a table with id="this". The following jQuery code doesn't work;

$("table#this").click(function() {
alert("Hey");
}

Do you know why this might be? Any help would be greatly appreciated!
__________________

Please login or register to view this content. Registration is FREE
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
 
Register now for full access!
Old 06-18-2009, 09:50 AM Re: Can't use jQuery to interact with returned ajax html
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You need to place any events intended for AJAX loaded content into the callback of the AJAX function, so that the event is bound to the object AFTER the content has loaded.

For example:
Code:
$("#my-div").load("/path/to/file.php", function() {
       $("table#this").click(function() {
                alert("Hey");
       }
});
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 06-18-2009, 12:24 PM Re: Can't use jQuery to interact with returned ajax html
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
You are a true gent. Thank you I'll get the implemented straight away
__________________

Please login or register to view this content. Registration is FREE
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
Reply     « Reply to Can't use jQuery to interact with returned ajax html
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19271 seconds with 12 queries