0
Ich versuche, json Daten von Rest Web-Services in HTML-Tabelle zu füllen. dies ist mein HTML-Codebefüllen Json Daten in HTML-Tabelle mit Ajax Anruf
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Employee List</title>
</head>
<body>
<h1>Employee List</h1>
<form>
<table id= "content">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Age</th>
<th>Salary</th>
<th>Address</th>
</tr>
</thead>
<tbody id = "emp">
</tbody>
</table>
</form>
<script>
$(document).ready(function(){
alert("1");
var data = $("#employee").val();
alert("2");
$.ajax({
url: '/rest/restemployees',
type: 'GET',
dataType: 'JSON',
success: function(data){
alert("3");
$.each(data, function(i,value){
$("#content tbody").append("<tr>" + "<td>" + value.id + "</td>" +
"<td>" + value.name + "</td>" +
"<td>" + value.age + "</td>" +
"<td>" + value.salary + "</td>" +
"<td>" + value.address + "</td>" + "</tr>")
});
},
error: function(data){
alert("4");
}
});
});
</script>
</body>
</html>
mir bitte
Anmerkung helfen: Warnungen genutzt werden einfach um den Fluss zu wissen
Inhalt der Tabellen-ID ist. Ich weiß nicht, wo der Fehler ist. kann mir jemand helfen, dieses Problem zu lösen