admin管理员组文章数量:1123233
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") }
});
}
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") }
});
}
Share
Improve this question
asked 10 hours ago
BogdanBogdan
72 bronze badges
2 Answers
Reset to default 1The 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.
async function AJAXSubmit(oFormElement) {
// Prevent the form from submitting in the default way
event.preventDefault();
your code comes here
Use event.preventDefault() before implementing your code and this should solve your issue.
本文标签: javascriptFetch Api redirect to pageStack Overflow
版权声明:本文标题:javascript - Fetch Api redirect to page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736559871a1944630.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论