I got problem.
When I choose image file, file is sending to server, but when it finish I don’t see alert but new blank page.
How to fix it?
Here is script
async function AJAXSubmit(oFormElement) {
fetch(oFormElement.action)
.then((response) => {
if (response.status === 200) { alert("ok") }
});
}
2
Answers
The issue most probably occurs because the form is being submitted in the traditional way (default form submission behavior), which reloads the page.
You should use
event.preventDefault()
to prevent default submission behaviour.Use event.preventDefault() before implementing your code and this should solve your issue.