简体   繁体   English

发布表单后如何防止页面重新加载?

[英]How can I prevent the page from reloading after posting a form?

Normally, I'd use AJAX for this, but the purpose of the form is to upload a file, which AJAX can't do. 通常,我会为此使用AJAX,但是表单的目的是上传文件,而AJAX无法做到。

Is there a way to let the form submit normally, but catch the response (JSON/XML or similar) and handle it in javascript without the page refreshing/redirecting? 有没有一种方法可以让表单正常提交,但可以捕获响应(JSON / XML或类似内容)并在javascript中处理它而无需刷新/重定向页面?

添加一个隐藏的iframe,然后使用target属性将表单发布到iframe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM