什么时候使用AJAX比较合适?
什么时候使用 AJAX 比较合适?
使用 AJAX 的优缺点是什么?
When is it appropriate to use AJAX?
what are the pros and cons of using AJAX?
回答我的最后一个问题:有些人似乎非常坚定地认为我应该只在情况合适的情况下使用 AJAX:我应该将 AJAX 逻辑添加到我的 PHP 类/脚本中吗?
In response to my last question: some people seemed very adamant that I should only use AJAX if the situation was appropriate: Should I add AJAX logic to my PHP classes/scripts?
回应 Chad Birch 的回答:是的,我指的是在开发标准"站点时,该站点将使用 AJAX 来获得好处,并且不会被其应用程序削弱.以一种会扼杀搜索排名的方式使用 AJAX 是不可接受的.因此,如果保持网站完整"需要更多的工作,那将是骗局".
In response to Chad Birch's answer: Yes, I'm referring to when developing a "standard" site that would employ AJAX for its benefits, and wouldn't be crippled by its application. Using AJAX in a way that would kill search rankings would not be acceptable. So if "keeping the site intact" requires more work, than that would be a "con".
推荐答案
这是一个相当大的主题,但您应该使用 AJAX 来增强用户体验,而不是让网站完全依赖它.请记住,搜索引擎和其他一些访问者将无法执行 AJAX,因此如果您依赖它来加载您的内容,那将不会对您有利.
It's a pretty large subject, but you should be using AJAX to enhance the user experience, without making the site totally dependent on it. Remember that search engines and some other visitors won't be able to execute the AJAX, so if you rely on it to load your content, that will not work in your favor.
例如,您可能认为让用户访问您的博客,然后让页面在他们已经在那里时使用 AJAX 动态加载最新文章会很好.但是,当 Google 尝试将您的博客编入索引时,它只会获取空白站点.
For example, you might think that it would be nice to have users visit your blog, and then have the page dynamically load the newest article(s) with AJAX once they're already there. However, when Google tries to index your blog, it's just going to get the blank site.
查找与此主题相关的资源的一个很好的搜索词是渐进式增强".那里有很多好东西,花一些时间关注周围的链接.这里有一个让你开始:
A good search term to find resources related to this subject is "progressive enhancement". There's plenty of good stuff out there, spend some time following the links around. Here's one to start you off:
http://www.alistapart.com/articles/progressiveenhancementwithjavascript/
相关文章