-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
60 lines (54 loc) · 2.09 KB
/
index.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chatbot ConfiguroWeb</title>
<link rel="stylesheet" href="style.css">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
</head>
<body>
<div class="wrapper">
<div class="title">ChatBot ConfiguroWeb</div>
<div class="form">
<div class="bot-inbox inbox">
<div class="icon">
<i class="fas fa-user"></i>
</div>
<div class="msg-header">
<p>Hola, ¿cómo puedo ayudarte?</p>
</div>
</div>
</div>
<div class="typing-field">
<div class="input-data">
<input id="data" type="text" placeholder="Escribe algo aquí.." required>
<button id="send-btn">Enviar</button>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$("#send-btn").on("click", function() {
$value = $("#data").val();
$msg = '<div class="user-inbox inbox"><div class="msg-header"><p>' + $value + '</p></div></div>';
$(".form").append($msg);
$("#data").val('');
// iniciar el código ajax
$.ajax({
url: 'message.php',
type: 'POST',
data: 'text=' + $value,
success: function(result) {
$replay = '<div class="bot-inbox inbox"><div class="icon"><i class="fas fa-user"></i></div><div class="msg-header"><p>' + result + '</p></div></div>';
$(".form").append($replay);
// cuando el chat baja, la barra de desplazamiento llega automáticamente al final
$(".form").scrollTop($(".form")[0].scrollHeight);
}
});
});
});
</script>
</body>
</html>