I have a button that grabs some data from the server using ajax, and when it's done, it it supposed to add a element to the DOM.
The element to add will be something like this
<div class="SomeClass">
<div class="SomeOtherClass">
<span class="Name">name from server</span>
<span class="Manufacturer">manufacturer from server</span>
</div>
<span class="Weight">weight from server</span>
</div>'
In my jQuery function that gets the data back from the server, what is the best way to create this structure, put the data (name, manufacturer and weight) from the server in at the correct places, and put it into the DOM. I have got it working like this:
$("#ItemList").append('<div class="SomeClass"><div class="SomeOtherClass"><span class="Name">' + value.name + '</span><span class="Manufacturer">' + value.manufacturer + '</span></div> ' +
'<span class="Weight">' + value.weight + '</span></div>');
But this does not look very good, and it's hard to see the proper structure.
What is the best way of doing this in a clean manner?