Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- $("#mydiv table tbody td").click(function() {
- alert("You clicked my <td>!" + $(this).html() +
- "My TR is:" + $(this).parent("tr").html());
- });
- $('#myform').submit(function()
- {
- try {
- var host = $("#host").val();
- var port = $("#port").val();
- var username = $("#username").val();
- var password = $("#password").val();
- var database = $("#database").val();
- $.ajax({
- type: "POST",
- url: "/management/connectDatabase",
- dataType: "JSON",
- data: "host="+host+"&port="+port+"&username="+username+"&password="+password+"&database="+database,
- cache: false,
- success:
- function(data){
- $('#mydiv').html(show_tables(data));
- },
- });
- return false;
- }
- catch(e){
- console.debug(e);
- }
- });
- });
- function show_tables(data)
- {
- var html = '<div id="mydiv">';
- html += '<table class="display" id="example">';
- html += '<thead><tr><th>Tables</th></tr></thead><tbody>';
- for (var tablesCount = 0; tablesCount < data.tables.length; tablesCount++){
- html += '<tr class=gradeA id="trtest">';
- html += '<td id="tdtest">' + data.tables[tablesCount] + '</td>';
- html += '</tr>';
- }
- html += '</tbody></table>';
- html += '</div>';
- return html;
- }
- $("#mydiv table tbody").on('click', 'td', function() {
- alert("You clicked my <td>!" + $(this).html() +
- "My TR is:" + $(this).parent("tr").html());
- });
- $("#mydiv table tbody").on('click', 'td', function() {
- alert("You clicked my <td>!" + $(this).html() + "My TR is:" + $(this).parent("tr").html());
- });
- $.post('ajax/test.html', function(data) {
- $('.result').html(data);
- // Add .click code here
- });
Add Comment
Please, Sign In to add comment