I'm a beginner at jQuery and I'm trying to parse JSON data from a div using the $.getJSON
function but it isn't working. Can you show me how can I do this? Here is the code I'm using:
<div id="json">
{"data":[
{"a":"b"},
{"a":"c"}
]}
</div>
<script>
$(document).ready(function() {
$.getJSON( $("#json").html() , function(json) {
$.each(json.data, function(index, value) { $('.data').append(value.a+'<br />'); } );
});
});
</script>
<div class="data"></div>