erzoolander
asked on
Build DOM elements from JSON / JQuery
I've got a JSON string that takes this form...
{"people":[{"name":"person 1","descri ption":"Th is is a brief description of my service.","image":"mandg1. jpg","type ":"first", "insured": "yes","lic ense":"N\/ A","pictur e":"mandg1 .jpg","yea rsinbusine ss":"8","d istance":1 5},{"name" :"person2" ,"descript ion":"This is a brief description of my service.","image":"mandg2. jpg","type ":"second" ,"insured" :"yes","li cense":"N\ /A","pictu re":"mandg 2.jpg","ye arsinbusin ess":"8"," distance": 19}]}
What I'd like to do is, via jQuery, build a group of divs based upon the "people" key...so in the instance above...you'd end up creating 2 elements...and append them to the div id="container". If there were 50 elements, you'd end up with 50 divs, etc etc etc.
<div id="container">
<div id="person1">
<p>Name: person1</p>
<p>Description: This is a brief description of my service</p>
</div>
<div id="person2">
<p>Name: person2</p>
<p>Description: This is a brief description of my service</p>
</div>
</div>
What would the jQuery syntax for that be? Thanks in advance!
{"people":[{"name":"person
What I'd like to do is, via jQuery, build a group of divs based upon the "people" key...so in the instance above...you'd end up creating 2 elements...and append them to the div id="container". If there were 50 elements, you'd end up with 50 divs, etc etc etc.
<div id="container">
<div id="person1">
<p>Name: person1</p>
<p>Description: This is a brief description of my service</p>
</div>
<div id="person2">
<p>Name: person2</p>
<p>Description: This is a brief description of my service</p>
</div>
</div>
What would the jQuery syntax for that be? Thanks in advance!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER