Please apologize my ignorance, I am very new to this.

So I have some code and am doing AJAX refreshes of some text on the page which works fine.

Now I want to refresh things which are more complicated than just a text string, such as a button which is generated by some html and php code. For instance the button should only appear when a certain condition is satisfied. How do I go about it? Specifically how do I pass it to the JSON?

Can I apply some function (which?) to the whole php+html construct which transforms it into a string?

As a potentially related question....
One of the variables I am refreshing is a simply "Yes"/"No" display. If I want to make it more prominent by changing the color, e.g. green text for "Yes", red text for "No", where do I put it? Do I need to put it into the JSON, or can I keep it out of it?

In that case I would just return a HTML string. So instead of "Yes" or "No" I'd return:

<span class="green">Yes</span>


<span class="red">No</span>