Untitled
unknown
plain_text
3 years ago
1.7 kB
5
Indexable
<!DOCTYPE html>
<html>
<head>
<title>Employee Cart</title>
<style>
body {
font-family: Arial, sans-serif;
}
#employeeTable {
border-collapse: collapse;
width: 100%;
}
#employeeTable th, #employeeTable td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
#employeeTable th {
background-color: #f2f2f2;
}
#employeeTable img {
height: 50px;
width: auto;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<table id="employeeTable">
<thead>
<tr>
<th>Name</th>
<th>Username</th>
<th>Email</th>
<th>Phone</th>
<th>Website</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script>
$(document).ready(function() {
// Make AJAX request to fetch JSON data
$.ajax({
url: 'https://jsonplaceholder.typicode.com/users',
dataType: 'json',
success: function(data) {
// Iterate over each user in the JSON data
$.each(data, function(index, user) {
// Append a new row to the table for each user
var row = $('<tr>');
row.append($('<td>').text(user.name));
row.append($('<td>').text(user.username));
row.append($('<td>').text(user.email));
row.append($('<td>').text(user.phone));
row.append($('<td>').text(user.website));
// Append the row to the table body
$('#employeeTable tbody').append(row);
});
}
});
});
</script>
</body>
</html>
Editor is loading...