Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Populating table with database and attaching element to each <tr>

I want to add functionality to each <tr> tag inside a table. Then use jQuery and when a <tr> element is clicked on/toggled an additional piece of information is shown. Each <tr> is dynamically generated when looping through the entries from the database, so which tag would this new element be appended.

Would this pose a problem as the the content for the additional element would have to someone be passed through jQuery?

Any ideas other methods to achieve this result?

Thanks =)

1 Answer

I'm not sure I completely understand what you're trying to do, but you can use jQuery and Ajax to 'dynamically' get new content from the database, by using something on the server side (PHP, Node.js or whatever) to query and return the results from the database.

Shouldn't be any issues, as long as the content is accessible from the same host/domain. If it's from another domain (or even port or protocol), you might get errors relating to the same-origin policy.