forked from rDrama/rDrama
fix lottery breaking bc of 1882653da6
parent
947c75d4bc
commit
f0e40534b0
|
@ -25,9 +25,9 @@ function showToast(success, message) {
|
||||||
bootstrap.Toast.getOrCreateInstance(document.getElementById(element)).show();
|
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();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', url);
|
xhr.open(method, url);
|
||||||
xhr.setRequestHeader('xhr', 'xhr');
|
xhr.setRequestHeader('xhr', 'xhr');
|
||||||
if (!form) form = new FormData();
|
if (!form) form = new FormData();
|
||||||
form.append("formkey", formkey());
|
form.append("formkey", formkey());
|
||||||
|
|
|
@ -53,7 +53,7 @@ function handleLotteryRequest(uri, method, callback = () => {}) {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append("formkey", formkey());
|
form.append("formkey", formkey());
|
||||||
form.append("quantity", purchaseQuantity);
|
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].onload = handleLotteryResponse.bind(null, xhr[0], method, callback);
|
||||||
xhr[0].send(xhr[1]);
|
xhr[0].send(xhr[1]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue