Replace divs with content from JSON call

majosisk

New Member
I am receiving content from a JSON call and I would like to populate 3 object that returned with response in \[code\]news_item\[/code\] class as follows:\[code\]<div class="news"> <div class="news_item" style="margin-left: 0 !important;"> <div class="ni_image"> <a href="http://stackoverflow.com/HaberDetay/TITLE/ID"><img src="http://stackoverflow.com/questions/13848471/IMAGE"width="203" height="109"/></a> </div> <div class="ni_text"> <div class="ni_text_title">TITLE</div> <div class="ni_text_content"> CONTENT </div> </div> </div> </div>\[/code\]I am able to receive the data as follows. but not quite sure how to populate the \[code\]news_item\[/code\] div as above. I also need to clear, \[code\]news\[/code\] and replace everything with data from JSON response.\[code\]var newsByCity = JSON.parse(msg); $.each(newsByCity, function (key, item) { alert("Code: " + item.City + " ,Name: " + item.Title + " ,Country: " + item.County); });\[/code\]any pointers? how can i do this?EDIT: i m getting back TITLE, ID, CONTENT etc. I just need to see how i can create this new divs.
 
Back
Top