I'm trying to fetch my json data into a table while connected to tomcat in xampp. I couldn't fetch the data after clicking on the button. The data need not appear.
Html File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
</head>
<body>
<br><br><br>
<div id="adminpage">
<h1 id="contentheader">Admin Page</h1>
<button class="getleads">Show Lead</button>
<br><br>
<table class="leadstable" border="2" align="center">
<thead>
<th>Name</th>
<th>Phone</th>
<th>Email Address</th>
<th>Nationality</th>
<th>Qualification</th>
<th>Course</th>
</thead>
<tbody id="tdata">
</tbody>
</table>
</div>
</body>
</html>
script.js
$(document).ready(function(){
$(".getleads").click(function(){
$.getJSON("jsoncontent.json", function(data){
$.each(data, function(key, value){
$("#tdata").append("<tr>" + "<td>" + value.name + "</td>" + "</tr>")
});
});
});
});
jsoncontent.json
{
"leads": [
{
"name": "Steady",
"phone":"98574856",
"email": "SteadyLim@Email.com",
"nationality":"Singaporean",
"qualification":"GCE A-Level",
"course":"Diploma in Web Development"
},
{
"name": "Michelee",
"phone":"85748596",
"email": "Micheleeyoke@nomail.com",
"nationality":"foreigner",
"qualification":"PSLE",
"course":"Diploma in Computer Science"
},
{
"name": "Oleary",
"phone":"94857458",
"email": "Olearynut@youmail.com",
"nationality":"Singaporean",
"qualification":"GCE O-Level",
"course":"Diploma in Web Development"
}
]
}
I want that the json data to appear after clicking on that .getleads button. As for now when I clicked the button, There's no error but it's just that the json data couldn't append into my table.