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
精彩评论