Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:47:40+00:00 2026-05-24T06:47:40+00:00

I’m trying to replace the contents of a td tag in a javascript function

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:47:41+00:00Added an answer on May 24, 2026 at 6:47 am

    Since jQuery calls always return a jQuery object they will never be null. To test if a wrapped set is empty or not you can check the length.

    ie. if (tdstatus.length > 0 && tdreason.length > 0)

    Also, I’m not sure what is invoking this function, but if it’s being used as an AJAX callback, the signature for it is actually f(data, textStatus, jqXHR).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Does anyone know how can I replace this 2 symbol below from the string
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.