-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (26 loc) · 867 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$('button#btn').click(function(){
carregarDados();
$('div#listagem').css('display','block');
})
$('button#btn-esconder').click(function(){
$('div#listagem').css('display','none');
})
function carregarDados() {
$.ajax({
url: '_xml/produtos.xml'
}).then(sucesso, falha);
function sucesso(arquivo) {
var elemento;
elemento = "<ul>";
$(arquivo).find('produto').each(function () {
var nome = $(this).find('nomeproduto').text();
var tempoentrega = $(this).find('tempoentrega').text();
elemento += "<li class='nome'>" + nome + "</li>";
elemento += "<li class='tempoentrega'>" + tempoentrega + "</li>";
});
elemento += "</ul>";
$('div#listagem').html(elemento);
}
function falha() {
}
}