html中怎么改状态,html – 如何在UI状态更改时更新wtf-form状态?

在这种情况下,我认为没有一种“正确”的方式 – 正确的方法取决于你想要达到的目标.

答:如果 – 例如 – 你不想因为某种原因搞乱JavaScript,你不介意重新加载页面,那么你可以像在代码示例中那样做.

B.另一方面,如果你只是想重新加载页面来改变表单颜色,那么我会说这是一个开销,简单的JS脚本在这种情况下会更优雅和用户友好.

编辑回答评论问题:

你能解释一下“重装页面”吗?

当您的浏览器使用标准HTTP方法(如GET和POST)与服务器通信以交换数据时,它必须在从服务器获得响应(这是对您的请求的答案)之后重新加载页面.

另一方面,如果您的页面使用AJAX(异步JavaScript和XML),那么事实并非如此.引用Wikipedia主题:

With Ajax,Web applications can send data to and retrieve from a

server asynchronously (in the background) without interfering with the

display and behavior of the existing page. By decoupling the data

interchange layer from the presentation layer,Ajax allows for Web

pages,and by extension Web applications,to change content

dynamically without the need to reload the entire page.

如果我决定使用JS并且我不重新加载页面,我会在选项’A’中松开什么?

无论哪种方式都有其优点和缺点,由您决定哪种方式可行.

Major advantages of Ajax:

1. It makes things short and fast.

2. Get rid of reloading page.

3. Very much useful for real time applications.

4. Reduces server load and saves bandwidth.

Major Disadvantages of Ajax:

1. Bookmarking problem.

2. Very bad for SEO.

3. Screen readers can’t access ajax.

4. Only the modern browsers supports it and if javascript is not enabled at the user end,your site will look ugly.

使用JS意味着它不会重新加载页面吗?

如果您使用Ajax与服务器和JS交换数据以将结果放在您的网站上,那么是 – 不需要重新加载.

回到你的代码示例 – 如果你只是想因为演示原因而改变表单颜色,并且对于你的应用程序而言表单的颜色并不重要,那么没有理由在服务器端进行.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值