Hello,
I have a question about JSON. I have made a connection with JSON to a HTML-file but it does not work.
Can someone help me? I get this error in the firebug in rule 15:
missing name after . operator $.each(data."46", function(index, item){
The rule 15 is bold.
Thanks in advance.
My code is: for JSON see below
HTML:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$.ajax({
url:"acteurs.json",
dataType: "json",
success: function(data){
//itereren over dataobject
$.each(data."46", function(index, item){ $("#content").append('<div id="46'+index+'"> item['46'] +'</div>');
$(".data").append('<div id="perc-os'+index+'" class="j2010">'+ item['0'] +'</div>');
$(".data").append('<div id="perc-os'+index+'" class="j2011">'+ item['1'] +'</div>');
$(".data").append('<div id="perc-os'+index+'" class="j2015">'+ item['2'] +'</div>');
});
}
}
);
});
</script>
</head>
<body>
<div id="content">
</div>
<div class="data">
</div>
</body>
</html>
JSON
{
"46": {
"0": "Matt",
"1": "Bomer",
"2": "100000",
"3": "White Collar",
"4": "drama",
"5": "18.2%;"
},
"25": {
"0": "David",
"1": "Boreanaz",
"2": "200000",
"3": "Bones",
"4": "drama",
"5": "36.4%;"
},
"63": {
"0": "Ty",
"1": "Burrell",
"2": "50000",
"3": "Modern Family",
"4": "comedy",
"5": "9.1%;"
},
}