I am having 2 questions 1st : I am trying to run this file but it is not even giving any error not showing result please tell what is the problem 2. I want to get the names in the dropdown as well so i have put select tag but I don't know how to use it to get the list of names...please suggest
My html file
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta content="utf-8" http-equiv="encoding">
<title>D3</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="my_script.js" type="text/javascript></script>
</head>
<body>
<button type="button">Click Me!</button>
<select>
</select>
</body>
</html>
My script.js file
$("button").click(function() {
$.getJSON("data.json",function(obj) {
$.each(obj, function(key, value){
$ ("ul").append("<li>"+value.name +"</li>");
});
});
});
My json file
[{
"name": "obs",
"date": "1458834026000"
"attr001": "brs1"
"attr002": "crs1"
"attr003": "drs1"
}, {
"name": "hid",
"date": "1458774000000"
"attr001": "ffrs1"
"attr002": "grrs1"
"attr003": "mno1"
}, {
"name": "qwe",
"date": "1425744000000"
"attr001": "klm1"
"attr002": "wer1"
"attr003": "iop1"
}, {
"name": "rty",
"date": "1458774000000"
"attr001": "yrs1"
"attr002": "qws1"
"attr003": "prs1"
}]