extract items from json encoded array with jquery
Posted: Fri Apr 25, 2014 1:05 pm
Hello im trying to echo an array into div boxes however i cant get it working probaly, so heres my question. how can i do so that this code will create a div box and populate it with my array
heres my code i have so far,
heres my code i have so far,
Code: Select all
and this is my array, its inside another array so double array, and is json encoded
$.each( data, function( key, value ) {
$.each( value, function( key2, value2 ) {
$('<h1/ id="test">').text(value2).appendTo('#search_results');
});
});
Code: Select all
i would like it to look like this
[{"id":"4","title":"test1"},{"id":"5","title":"test2"},{"id":"6","title":"test3"},{"id":"7","title":"test4"},{"id":"9","title":"test6"}]
Code: Select all
<div class="myclass">
<h2>The title</h2>
<h2>The id</h2>
</div>
<div class="myclass">
<h2>The title</h2>
<h2>The id</h2>
</div>