-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.html
71 lines (47 loc) · 1.41 KB
/
app.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<html>
<body>
<h1>OLA PESSOAL</h1>
<form id="formulario">
<label for="nome"></label>
<input type="text" id="sendNome" placeholder="Insert your name...">
<label for="sobrenome"></label>
<input type="text" id="sendSobrenome" placeholder="Insert your last name...">
<input type="submit" onclick="enviar(event)" value="Enviar!">
</form>
<input type="submit" id="gabriel" value="Gabriel">
<input type="submit" id="mylena" value="Mylena">
<div id="nome"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
//BOTAO GABRIEL
$('#gabriel').on('click', function(event){
event.preventDefault()
$.get('http://localhost:3000/clientes/1', function(data){
console.log(data)
$('#nome').text(data[0].Nome)
})
})
//BOTAO MYLENA
$('#mylena').on('click',function(event){
event.preventDefault()
$.get('http://localhost:3000/clientes/2', function(data){
console.log(data)
$('#nome').text(data[0].Nome)
})
})
//POST NO BANCO
function enviar(event){
event.preventDefault()
var sendNome = $('#sendNome').val();
var sendSobrenome = $('#sendSobrenome').val();
var objSend = {
sendNome: sendNome,
sendSobrenome : sendSobrenome
}
$.post('http://localhost:3000/clientes', objSend, function(data){
console.log(data)
})
}
</script>
</body>
</html>