-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrection.js
More file actions
24 lines (22 loc) · 690 Bytes
/
correction.js
File metadata and controls
24 lines (22 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
document.getElementById('correctionForm').addEventListener('submit', function(event) {
event.preventDefault();
var textInput = document.getElementById('textInput').value;
// Send the text to the server for correction
fetch('correction.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'text=' + encodeURIComponent(textInput)
})
.then(function(response) {
return response.text();
})
.then(function(correctedText) {
// Display the corrected text
document.getElementById('correctedText').textContent = correctedText;
})
.catch(function(error) {
console.error('Error:', error);
});
});