I'm trying to replace the contents of a td tag in a javascript function but can't figure out what's going on. Here is the function.
function actionCompleted(response, status, data) {
// Set the id for row
var rowId = "#rowId-" + response.fieldname;
// Set the ids for the two table cells we need
var tdstatusId = "#tdstatusId-" + response.id;
var tdreasonId = "#tdreasonId-" + response.id;
alert(tdreasonId);
try {
//get the table cell for the status
var tdstatus = $('#itemDetails').find(rowId).find(tdstatusId);
//get the table cell for the reason
var tdreason = $('#itemDetails').find(rowId).find(tdreasonId);
//Make sure we found our cells
if (tdstatus != null && tdreason != null) {
//Set our cell content
//tdstatus.html(response.ChangeStatus);
//tdreason.text(response.message);
tdstatus.html('TEST');
tdreason.text('TEST');
}
}
catch (e) {
alert(e.toString());
}
}
I first thought there might be a problem with jquery finding the td controls, so I added the null check.
Then I thought it was the .text() so I tried .html().
I thought maybe it was swallowing an exception so I added the try..catch.
Then I thought it might be an issue with the response object the function received, so I threw some alerts in there and they have the values I need.
I checked the Ids and made sure they matched the id's found in the html of the page.
I've checked everything I could think of. But my code simply doesn't work. The first one of the two TD elements I'm trying to set contains two links (a tags), but the second one is empty. So I don't think that has anything to do with it. I'm at wits end here trying to figure this out.
Is there something I'm doing wrong? Could there be something else that would cause this behavior?
Thanks in advance.