Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting TD content using javascript/jquery
    text
    copied!<p>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.</p> <pre><code>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 &amp;&amp; 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()); } } </code></pre> <p>I first thought there might be a problem with jquery finding the td controls, so I added the null check. </p> <p>Then I thought it was the .text() so I tried .html(). </p> <p>I thought maybe it was swallowing an exception so I added the try..catch.</p> <p>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.</p> <p>I checked the Ids and made sure they matched the id's found in the html of the page.</p> <p>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.</p> <p>Is there something I'm doing wrong? Could there be something else that would cause this behavior?</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload