-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (26 loc) · 1008 Bytes
/
script.js
File metadata and controls
31 lines (26 loc) · 1008 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
25
26
27
28
29
30
31
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('rankPredictionForm').addEventListener('submit', predictRank);
});
function predictRank(event) {
event.preventDefault();
const formData = new FormData(document.getElementById('rankPredictionForm'));
const predictionDetails = {};
formData.forEach((value, key) => {
predictionDetails[key] = value;
});
// Call the savePrediction function with predictionDetails
savePrediction(predictionDetails);
// Reset form after prediction
document.getElementById('rankPredictionForm').reset();
}
async function savePrediction(predictionDetails) {
const response = await fetch('/save-prediction', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(predictionDetails)
});
const data = await response.json();
console.log(data); // Log the response from the server
}