简体   繁体   English

一些设计决定,您能给我一些建议吗?

[英]Some design decisions, Could you give me some advice?

All my forms submit to a php script by Ajax. 我所有的表单都提交给Ajax的php脚本。 the php script just like a controller. 的PHP脚本就像一个控制器。

I think this could be more user friendly. 我认为这可能更加用户友好。 if something goes wrong, the user doesn't need to leave the current page. 如果出现问题,则用户无需离开当前页面。

but i don't see any website do in this way. 但我看不到任何网站都以这种方式进行。

he downside is the php runtime have to load twice: one in the posting process. 他的缺点是php运行时必须加载两次:在发布过程中加载一次。 one for showing the result. 一个用于显示结果。

First of all, as Pekka commented, there are lots of websites that use ajax technique to submit a form. 首先,正如Pekka所说,有很多网站都使用Ajax技术提交表单。

If I correctly interpreted your question, usually, I think the best asynch pattern to solve the "form problem", in design terms is this: 通常,如果我正确地解释了您的问题,我认为在设计方面,解决“表单问题”的最佳方式是:

=> html form => HTML表格

=> default submit event stopped by JS => JS停止了默认的提交事件

=> JS client checks (ie email/phone) validation => JS客户端检查(即电子邮件/电话)验证

=> ajax call to a backend script (php, java, ruby, etc) - it loads just once! => ajax调用后端脚本(php,java,ruby等)-它仅加载一次!

=> serverside checks, "echoing" a response =>服务器端检查,“回应”响应

=> ajax call response, handled by JS =>由JS处理的ajax调用响应

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

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