I have a button that captures some data from the server using ajax, and when this is done, it should add an element to the DOM.
The item to add will look 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, which returns data from the server, how best to create this structure, put the data (name, manufacturer and weight) from the server in the right places and put it in the DOM. It works for me 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 is difficult to see the correct structure.
What is the best way to do this in its purest form?
source share