How to insert/update an item in a specific column of a dynamic table?

I have a dynamic table as of here As you can see, I have a column for "Status" which i hope to get status reply through this done(function()). This is what i've tried http://jsfiddle.net/yvonnezoe/nbrSR/1/

I set the id for that column as id="status_' + rowID because each row will be different. Then, i find each column of each row by setting a variable

eachStatus = $row.find('td:nth-child(5)').attr('id');

After that, i posted that to a python function and it will get a reply of either on or off (for now). In this Fiddle, it won't work because the python function and the real system aren't here. I just want to find out if i'm doing it correct by finding that column and do an .append to show the status? Well, if it is appended to a new div, the on and off can be displayed. But for this one, it never shows up in the table. Why and how should i do it? Will it be updated as well since I'm doing a setInterval, looping every 5 seconds?

    $.post('/request', {
    inputText: fbNum,
    key_pressed: fbType.toString()}).done(function (reply) {
    if (reply == "on") {
        $('#status_table tr #status_' + eachStatus).append("on ");
    } else {
        $('#status_table tr #status_' + eachStatus).append("off ");
    }
    });

FYI, you have to select an option, key in a number, check the checkbox and press "monitor". It will loop every 5 seconds.

Answers


$('#status_table tr #status_' + eachStatus).append("on ");

should be

$('#status_table tr #' + eachStatus).append("on ");

instead because eachStatus already included status.

you may want to do an .empty() before the .append() so that new status can replace the previous one.


Need Your Help

Run a php script in ruby on rails

php ruby-on-rails ruby

In one of my Rails application I need to execute a PHP file from the Controller of Ruby on Rails app. The PHP file meant for some database editing.

c support in mobile platforms

iphone android blackberry webos

Is C a language that can be used on Android, BlackBerry, iPhone, Windows Mobile, and WebOS?

Get dimensions of UIView Class for CGRects?

ios uiview core-graphics bounds cgrect

I am currently working on an app that draws a series of rectangles (CGRect) on a view and sizes them based on the size of the UIView. This code is contain in a class file that inherits UIView