Skip to content

Commit

Permalink
12314
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMoreira committed Nov 4, 2023
1 parent 8f2b276 commit 837f248
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pages/json-loader/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Caique M",
"age": 20,
"address": "St Antonio Luiz Estefani",
"city": "Florida PTA"
}
43 changes: 43 additions & 0 deletions pages/json-loader/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XML</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>ATT datos</h1>
<ul id="data-list">

</ul>
<script>
function loaderlist() {
$.ajax({
type: "GET",
dataset: "json",
url: "data.json",
cache: false,
success: function(data){
$("#data-list").empty(); // limpa qualquer informação antes de atualizar

$("#data-list").append(
"<li>Nome: "+ data.name + "</li>"+
"<li>Idade: " + data.age + "</li>"+
"<li>Endereço: " + data.address + "</li>" +
"<li>Cidade: " + data.city + "</li>"+
"<hr>"
);

},
error: function(xhr, status, error){
console.error("Erro ao carregar dados do arquivo JSON: " + error);
}
});
}

loaderlist();
setInterval(loaderlist, 2000);
</script>
</body>
</html>

0 comments on commit 837f248

Please sign in to comment.