Suppose I got a div that uses AJAX to retrieve prices and information about products, and appends the new products to current results.
<div id="product">
<div class="label">Price: <div class="price">$10.90</div></div>
<div class="label">Sales Price: <div class="price">$9.90</div></div>
</div>
I can do: 1) Get the price and data only. Then iterate through these results and have the Javascript create the div dynamically for each product.
Problem with this: If HTML structure for the div changes (say the class for price changes), I potentially need to change it in 2 places. In the static HTML, as well as in the Javascript.
2) Or is it better practice to have the server return the actual HTML to append to the page? But wouldn't this be messy because the design isn't separate from business logic, and the actual HTML structure might change?
Or is there a 3rd alternative I'm missing?