We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第52天 From表单提交时为什么会刷新页面?怎么预防刷新?
The text was updated successfully, but these errors were encountered:
因为早期网页交互模型只能是浏览器提交数据给服务器,服务器做出响应重新返回一个页面,浏览器加载这个页面进行显示。早期前端没有编程式发送网络请求的 API,更没有前端路由管理的概念,所以表单提交跳转页面是广泛接受的方案。
不想刷新可以使用 JS 拦截 form 的 onsubmit 事件,阻止掉浏览器的默认行为,然后用 ajax/fetch 和后台交互。另一个偏方是使用 iframe 作为 form 的 target,不过 JS 处理方面不如让浏览器别管自己全手动发请求来得简单。
Sorry, something went wrong.
因为早期网页交互模型只能是浏览器提交数据给服务器,服务器做出响应重新返回一个页面,浏览器加载这个页面进行显示。早期前端没有编程式发送网络请求的 API,更没有前端路由管理的概念,所以表单提交跳转页面是广泛接受的方案。 不想刷新可以使用 JS 拦截 form 的 onsubmit 事件,阻止掉浏览器的默认行为,然后用 ajax/fetch 和后台交互。另一个偏方是使用 iframe 作为 form 的 target,不过 JS 处理方面不如让浏览器别管自己全手动发请求来得简单。
No branches or pull requests
第52天 From表单提交时为什么会刷新页面?怎么预防刷新?
The text was updated successfully, but these errors were encountered: