Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
表单处理
|
81
/promo-email/thank-you
页的访问量大体上跟促销邮件的订阅用户数相关。这种做法实现
起来也很直观,但有一些不足。这种做法意味着你要为每一种可能分配一个
URL
,这
意味着要设计页面、写页面代码并维护。还有一处不足是它的用户体验也不是最优的。
用户愿意看到感谢的话,但他们为此还得返回到原来的页面,或者转到想要的页面。目
前先采用这种做法,第
9
章再切换到使用
flash
消息(不要与
Adobe Flash
混淆)
。
重定向至最初页面,包含一条 flash 消息
对于遍布全网的小表单(例如输入邮箱订阅),最好的用户体验是不打断用户的页面导
航。也就是说,需要提供一种提交邮箱地址而不离开当前页面的方法。当然,一种方
法就是使用
Ajax
。但如果不想使用
Ajax
(或者为了保证用户体验
,你需要一种回退机
制),则可以重定向到用户原先所在的页面。最简单的做法就是使用表单中的一个隐藏
域,这个隐藏域存放了当前的
URL
。既然你希望在原先的页面给出反馈
,告知用户提
交已经接收了,就可以使用
flash
消息。
重定向至新页面,包含一条 flash 消息
大表单通常都有自己的页面,提交表单之后还停留在表单页面就没有什么意义了。这种
情况下,你需要判断出用户可能想去哪里并相应地重定向。例如,如果你在开发后台管
理功能并创建了一个新的度假套餐表单,那么可以合理推测,在提交这个表单后,用户
会想跳转到所有套餐列表的管理页面。即使如此,你还是应该提供一条
flash
消
息,告
知用户表单提交的结果。
如果你在使用
Ajax
,推荐使用专门的 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099