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

Jackie Jen
2,723 PointsHow to add a html button to perform task in datatable jquery plugin
I would like to use datatable jquery plugin to hide/ show extra information. Below is an example on datatable showing hide and show function http://datatables.net/examples/api/row_details.html
when user click the show function i would like to have a html button to let user click to perform some action. But I have no idea on how to add a button on that table. since the data is fetch using JSON.
Could anyone guide me on how to do it?
2 Answers

SL Starr
17,543 PointsAdding the button should be easy in the last table row using <button></button>
with the necessary attributes. The tough question is what do you intend the button to do? You will likely need to use a javascript or jquery event listener coupled with AJAX to make a GET or POST request to the server which you could respond to with php on the server side. Dave McFarland's jQuery and AJAX section in the AJAX basics course may be the best place to start formulating your solution.

Jackie Jen
2,723 PointsThanks SL, The button is send email in php when clicked. In php, i knw how to send an email. but I only have very little knowledge on AJAX to make POST request to the server side. Is there any document or example to refer?

Adrian Zamfir
13,529 PointsHope this helps you: http://api.jquery.com/jquery.ajax/
Hugo Paz
15,622 PointsHugo Paz
15,622 PointsIf you look at the javascript, you can see the structure of the table there. You can add your button there.