ajax中拼接字符串规则_6个AJAX规则

ajax中拼接字符串规则

AJAX, or Asyncronous JavaScript And XML, has been around for a few years now. Web Developers have done some really great things with AJAX, but I've also come across some horrible uses of AJAX. I've coupled together my experience as a Web Programmer and a lowly web user and have come up with six AJAX rules to live by.

AJAX或异步JavaScript和XML已经存在了几年。 Web开发人员使用AJAX所做的事情确实很棒,但是我也遇到过AJAX的一些可怕用途。 我将自己作为Web程序员和低级Web用户的经验结合在一起,提出了6条AJAX规则可以依靠。

AJAX增强而不是功能 (AJAX to Enhance, Not to Function)

First and foremost, the important part of creating a quality website is making the site work. How? Doesn't matter, as long as the user knows it works. A typical user will even overlook loading speed if the site does what they want it to. That said, do you really want a user to be able to turn off JavaScript and have your site stop working for them? The one visit your website doesn't work for them, they're not coming back. Make everything works using standard page refreshes first, then come back and AJAXify your site.

首先,创建优质网站的重要部分是使网站正常工作。 怎么样? 没关系,只要用户知道它可以工作。 如果网站按照他们的意愿去做,那么典型的用户甚至会忽略加载速度。 也就是说,您是否真的希望用户能够关闭JavaScript并让您的网站停止为他们服务? 您网站的一次访问对他们而言无效,他们也不会回来。 首先使用标准页面刷新功能使一切正常,然后再返回并AJAXify您的网站。

始终让用户知道发生了什么 (Always Let the User Know What's Going On)

There's nothing worse than clicking something and seeing nothing happen for two seconds. Users are used to click and go, or at least click and watch the progress bar move. Remember that AJAX is a relatively new technology -- if the user sees nothing happen, they believe your website is broken. I suggest using an unobtrusive message that fades in and out gracefully.

没有什么比单击某些东西并在两秒钟之内看不到任何东西更糟糕的了。 用户习惯于单击并继续,或者至少单击并观看进度条的移动。 请记住,AJAX是一项相对较新的技术-如果用户看不到任何变化,他们就会认为您的网站已损坏。 我建议使用一条不引人注意的消息,该消息会优雅地淡入淡出。

你是用AJAX做的吗? 凉! 谁在乎? (You Did It With AJAX? Cool! Who Cares?)

Face it -- For most websites, 90+ percent of users don't know what AJAX is or why it's cool. I appreciate a good AJAX script, but does anyone else? Likely not. Unless you have a website geared towards Web Professionals, do your users a favor and hide your "Made Using AJAX" message. I don't care what voodoo magic you use as long as the website functions.

面对现实-对于大多数网站,超过90%的用户不知道什么是AJAX或为什么它很棒。 我赞赏一个好的AJAX脚本,但是还有其他人吗? 可能不会。 除非您有一个面向Web专业人士的网站,否则请您的用户帮个忙,并隐藏您的“使用AJAX制作”消息。 只要网站正常运作,我都不会在乎您使用什么巫毒术。

最后的AJAX (AJAX at the End)

Delivering the web project is the number one goal, so add your AJAX functionality toward the end of the project or after the website is done. Sure, AJAX can save a page refresh, but users are used to the old-fashioned way, waiting or not. I can't imagine your customer being satisfied with "It's not done, but look at how this box gets updated without the page being refreshed!" I'll take a working, old-fashioned (actually, standard is probably a better word) website with the promise of AJAX later over a late project any day.

交付Web项目是第一目标,因此在项目结束时或在网站完成后添加AJAX功能。 当然,AJAX可以保存页面刷新,但是用户习惯了老式的方式,无论是否等待。 我无法想象您的客户会对“这还没有完成,但请看看如何在不刷新页面的情况下更新此框”感到满意。 我将使用一个老式的(实际上, 标准可能是一个更好的词)老式网站,并承诺在以后的任何一个较晚的项目中都使用AJAX。

安全规则仍然适用 (The Security Rules Still Apply)

The URL of your AJAX may be hidden in your code so that most users don't see it, but I bet you I can find it. If it can be found, it can be exploited. Don't assume that because you made your web form or page code bulletproof that a user can't manipulate your script. Make sure to scrub the GET and POST variables before doing any AJAX script processing.

您的AJAX的URL可能隐藏在您的代码中,以便大多数用户看不到它,但是我敢打赌,我可以找到它。 如果可以找到它,则可以被利用。 不要以为您是因为使Web表单或页面代码具有防弹性而使用户无法操纵脚本。 在执行任何AJAX脚本处理之前,请确保清除GET和POST变量。

AJAX节省了加载时间...但是您JavaScript库却没有 (AJAX Saves Load Time...But Your JavaScript Library Doesn't)

Your AJAX code saves a user a page refresh, which allows for the header, footer, and navigation to NOT be reloaded? Cool. Your JavaScript library is 80kb? Not cool. Be sure to only load your library when needed, and don't add any more code than you absolutely need for the page. Exchanging load times, in this case, isn't efficient or user-friendly.

您的AJAX代码可为用户保存页面刷新,从而可以不重新加载页眉,页脚和导航? 凉。 您JavaScript库为80kb? 不酷 确保仅在需要时才加载库,并且不要添加超出页面绝对需要的代码。 在这种情况下,交换加载时间既不高效也不友好。

翻译自: https://davidwalsh.name/ajax-rules-to-live-by

ajax中拼接字符串规则

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值