rDrama/files/assets/js/report_post_modal.js
2021-12-10 11:17:34 -06:00

27 lines
No EOL
712 B
JavaScript

function report_postModal(id) {
submitbutton=document.getElementById("reportPostButton");
submitbutton.onclick = function() {
this.innerHTML='Reporting post';
this.disabled = true;
var xhr = new XMLHttpRequest();
xhr.open("POST", '/report/post/'+id, true);
var form = new FormData()
form.append("formkey", formkey());
form.append("reason", document.getElementById("reason").value);
xhr.withCredentials=true;
xhr.onload=function() {
document.getElementById("reportPostFormBefore").classList.add('hidden');
document.getElementById("reportPostFormAfter").classList.remove('hidden');
};
xhr.onerror=function(){alert(errortext)};
xhr.send(form);
}
};