fix availabilityJson post not working error: should pass CSRFToken into the function
This commit is contained in:
parent
0f17b3405e
commit
5d670c1dc5
@ -124,7 +124,7 @@ function Prompt() {
|
||||
}
|
||||
}
|
||||
|
||||
function roomReservation(id) {
|
||||
function roomReservation(id, csrfToken) {
|
||||
document.getElementById("check-availability").addEventListener('click', () => {
|
||||
let html = `
|
||||
<form id="check-availability-form" action="/availability-json" method="post" novalidate class="needs-validation">
|
||||
@ -158,7 +158,7 @@ function roomReservation(id) {
|
||||
callback: (result) => {
|
||||
const formElem = document.getElementById("check-availability-form");
|
||||
let formData = new FormData(formElem);
|
||||
formData.append("csrf_token", "{{.CSRFToken}}");
|
||||
formData.append("csrf_token", csrfToken);
|
||||
formData.append("room_id", id)
|
||||
|
||||
fetch('/availability-json', {
|
||||
|
@ -30,6 +30,6 @@
|
||||
{{end}}
|
||||
{{define "js"}}
|
||||
<script>
|
||||
roomReservation("1");
|
||||
roomReservation("1", {{.CSRFToken}});
|
||||
</script>
|
||||
{{end}}
|
||||
|
@ -30,6 +30,6 @@
|
||||
{{end}}
|
||||
{{define "js"}}
|
||||
<script>
|
||||
roomReservation("2");
|
||||
roomReservation("2", {{.CSRFToken}});
|
||||
</script>
|
||||
{{end}}
|
||||
|
Loading…
Reference in New Issue
Block a user