From f0e40534b09eb8e1a516b68469643487a438fc52 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 13 Aug 2023 17:06:32 +0300 Subject: [PATCH] fix lottery breaking bc of 1882653da65b83e73fc9c057c8ad48c41e7fea74 --- files/assets/js/core.js | 4 ++-- files/assets/js/lottery.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 6a444fcb0..b84b22dc5 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -25,9 +25,9 @@ function showToast(success, message) { bootstrap.Toast.getOrCreateInstance(document.getElementById(element)).show(); } -function createXhrWithFormKey(url, form=new FormData()) { +function createXhrWithFormKey(url, form=new FormData(), method='POST') { const xhr = new XMLHttpRequest(); - xhr.open('POST', url); + xhr.open(method, url); xhr.setRequestHeader('xhr', 'xhr'); if (!form) form = new FormData(); form.append("formkey", formkey()); diff --git a/files/assets/js/lottery.js b/files/assets/js/lottery.js index 908c54923..dda364638 100644 --- a/files/assets/js/lottery.js +++ b/files/assets/js/lottery.js @@ -53,7 +53,7 @@ function handleLotteryRequest(uri, method, callback = () => {}) { const form = new FormData(); form.append("formkey", formkey()); form.append("quantity", purchaseQuantity); - const xhr = createXhrWithFormKey(`/lottery/${uri}`, method, form); + const xhr = createXhrWithFormKey(`/lottery/${uri}`, form, method); xhr[0].onload = handleLotteryResponse.bind(null, xhr[0], method, callback); xhr[0].send(xhr[1]); }