I have a JSON response, something like the following:
[
[
"hospital_name",
"Average Covered Charges",
"Average Total Payments",
"Total Discharges"
],
[
"MERCY REGIONAL HEALTH CENTER",
6888.8181818182,
2890.5454545454,
11
],
[
"BUTLER MEMORIAL HOSPITAL",
13699.818181818,
2934.5454545454,
11
],
[
"METHODIST MANSFIELD MEDICAL CENTER",
23913.909090909,
2964.8181818182,
11
],
[
"EMORY JOHNS CREEK HOSPITAL",
10976.727272727,
2993.5454545454,
11
]
]
and I am trying to do something like this:
success:(function(data) {
jQuery.each(data, function(key, value) {
jQuery('table[name=drg_table]')
.append(
jQuery('<td>').text(key[0]),
jQuery('<td>').text(key[1]),
jQuery('<td>').text(key[2])
);
});
}
But I'm not sure that this is the correct way to update my table (which already exists). I simply want to update whole table with new values.