Omnibus commited on
Commit
c9b4514
·
1 Parent(s): 7fb96f8

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +19 -17
index.html CHANGED
@@ -4,6 +4,8 @@
4
  <title>
5
  How To Get URL Parameters using JavaScript?
6
  </title>
 
 
7
  </head>
8
 
9
  <body>
@@ -25,24 +27,24 @@ Current URL
25
 
26
  <button onclick="getParameters()"> Get URL parameters </button>
27
 
28
- <button onclick="returnsUserMessage()">Send to python</button>
29
- <div id=output></div>
30
-
31
  <script>
32
- async function returnsUserMessage() {
33
- var user_input = document.getElementById("input-chat").value;
34
- var bot_reponse = await fetch('localhost/response',
35
- {
36
- method: 'POST',
37
- headers: {
38
- 'Content-Type': 'application/json'
39
- },
40
- body: JSON.stringify({user_response: user_input})
41
- });
42
- document.getElementById('output').innerHTML = "maybe worked";
43
-
44
- // Then you need to present the bot response in your element
45
- }
46
  </script>
47
 
48
 
 
4
  <title>
5
  How To Get URL Parameters using JavaScript?
6
  </title>
7
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
8
+
9
  </head>
10
 
11
  <body>
 
27
 
28
  <button onclick="getParameters()"> Get URL parameters </button>
29
 
30
+ <input type="text" id="input">
31
+ <button onclick="sendData()">Send Data</button>
32
+ <div id="output"></div>
33
  <script>
34
+ function sendData() {
35
+ var value = document.getElementById('input').value;
36
+ $.ajax({
37
+ url: '/process',
38
+ type: 'POST',
39
+ data: { 'data': value },
40
+ success: function(response) {
41
+ document.getElementById('output').innerHTML = response;
42
+ },
43
+ error: function(error) {
44
+ console.log(error);
45
+ }
46
+ });
47
+ }
48
  </script>
49
 
50