diff --git a/app/static/app.js b/app/static/app.js index 97d886d..dfa8537 100644 --- a/app/static/app.js +++ b/app/static/app.js @@ -283,8 +283,9 @@ function submitPdf(eve) { submitForm(formdata); } async function submitForm(formData) { + var updateEventSource = None; try { - const updateEventSource = new EventSource("/get_censor_status/" + doc.fID); + updateEventSource = new EventSource("/get_censor_status/" + doc.fID); modal.style.display = "flex"; // console.log("http://127.0.0.1:8000/get_censor_status/" + doc.fID); @@ -304,7 +305,9 @@ async function submitForm(formData) { method: "POST", body: formData, }); - updateEventSource.close(); + if (updateEventSource !== None) { + updateEventSource.close(); + } modal.style.display = "none"; //let responseJSON=await response.json(); if (response.ok) {