File size: 751 Bytes
779624b
1ef167e
 
779624b
1ef167e
 
779624b
1ef167e
 
 
779624b
1ef167e
 
 
779624b
1ef167e
 
 
 
779624b
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
document.addEventListener('DOMContentLoaded', () => {
    const form = document.querySelector('#sepsis-prediction form');
    const result = document.querySelector('#sepsis-result');
  
    form.addEventListener('submit', async (event) => {
      event.preventDefault();
  
      const formData = new FormData(form);
      const urlParams = new URLSearchParams(formData);
      const url = `/sepsis/predict?${urlParams.toString()}`;
  
      try {
        const response = await fetch(url);
        const data = await response.json();
  
        result.textContent = data.statement;
      } catch (error) {
        console.error('Error:', error);
        result.textContent = 'An error occurred while processing the request.';
      }
    });
  });