开发者

Some design decisions, Could you give me some advice?

开发者 https://www.devze.com 2023-02-03 16:37 出处:网络
All my forms submit to a php script by Ajax. the php script just like a controller. I think this could be more user friendly. if something goes wrong, the user doesn\'t need to leave the current page

All my forms submit to a php script by Ajax. the php script just like a controller.

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 webs开发者_运维百科ite do in this way.

he downside is the php runtime have to load twice: one in the posting process. one for showing the result.


First of all, as Pekka commented, there are lots of websites that use ajax technique to submit a form.

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

=> default submit event stopped by JS

=> JS client checks (i.e. email/phone) validation

=> ajax call to a backend script (php, java, ruby, etc) - it loads just once!

=> serverside checks, "echoing" a response

=> ajax call response, handled by JS

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号