Hi i am currently working on a small project where I am supposed to query a JSON API with the format
{
"results": [
{
"livingstd": "80%",
"place": "ClassA"
},
{
"livingstd": "50%",
"place": "ClassC"
}
...
]
}
I am supposed to show the livings td whenever i hover over to a mini house icon.
so i wrote a javascript but it doesnt work. and I dont understand what went wrong. Can anyone shed some light on this? It doesn't show anything at all
<script type="text/javascript" src="js/function1.js"></script>
<script>
$(document).ready(function (e) {
//api url
var url = "dummyurl";
//store search term
var query;
//when the user hover over
$("button").hover(function (e) {
//get value and store in variable
query = $("#query").val();
//get the json file
$.getJSON(url + query, function (json) {
$.each(json.results, function (i, occupancy) {
$("results").append('<p>' + occupancy.occupancy + 'at' + occupancy.time + '</p>')
});
});
});
});
</script>
debugger;in your code while the debugging console open will let you to debug your js script easily, and this will ease us to troubleshoot your issue, your question are too broad which hard for us to troubleshoot