-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn.js
More file actions
37 lines (30 loc) · 999 Bytes
/
Copy pathreturn.js
File metadata and controls
37 lines (30 loc) · 999 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
32
33
34
35
36
37
function navigate(page) {
window.location.href = page;
}
function logout() {
localStorage.removeItem('currentUser');
window.location.href = 'signin.html';
}
document.getElementById('returnBookForm').addEventListener('submit', function (e) {
e.preventDefault();
const data = {
studentId: document.getElementById('studentId').value,
studentName: document.getElementById('studentName').value,
bookTitle: document.getElementById('bookTitle').value,
returnDate: document.getElementById('returnDate').value
};
fetch('http://localhost:5000/return-book', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
})
.then(res => res.json())
.then(response => {
alert(response.message);
document.getElementById('returnBookForm').reset();
})
.catch(error => {
console.error('Error:', error);
alert('Error returning book.');
});
});