WordPress:AJAX

来自站长百科
Fludlen讨论 | 贡献2008年6月20日 (五) 10:19的版本
跳转至: 导航、​ 搜索

What is Ajax?

Ajax是什么?

Ajax (Asynchronous JavaScript And XML) is a technology that allows a web page to perform actions or update dynamically, without completely reloading. The idea is that by using Ajax technology, a web site can be more responsive and interactive than a non-Ajax site. For instance, without Ajax, Google Maps might require you to click a link on the left side of the map and wait for the page to reload in order to scroll the map to the left. With Ajax, you can instead simply drag the map to scroll, and while there might be a small delay, it is a much shorter delay and less disruptive process than if you had to wait for the entire page to load.

Ajax(异步JavaScript和XML)是一个技术,能够使网页动态地执行一个行动或者更新,不需要重新地载入。通过使用Ajax技术,一个网站比一个非Ajax的站点,反应更加灵敏,互动性更强。例如,没有Ajax,Google地图可能要求你点击地图左边的一个链接,并且等待网页重新载入来将地图滚至左边。拥有了Ajax之后,你可以简单地将地图拖拉到滚至左边,就可以了,但是可能会有一点耽搁时间,但是这相对与你需要等待整个网页载入而言,只是一个简短的耽搁时间,而且这个过程的破坏性也更小。

If you already know about Ajax, and want to use it in a plugin you are developing, skip to WordPress:AJAX in Plugins.

如果你已经知道了关于Ajax的信息,而且想在一个你发展的插件中使用Ajax,跳到插件中的AJAX

How does Ajax work?

Ajax是怎样运行的?

Ajax technology is actually fairly simple to describe. Basically, the web programmer connects a link, button, or some other type of user interface element on the web page to a JavaScript program. When the user activates the interface (clicks on the link, drags the mouse, etc.), the JavaScript program sends some information or a request for data to a URL on the web server. Next, a program on the web server (probably also created by the web programmer) processes the request and sends back a response or some data. Typically the data is in XML format, but that is not actually required. When the data or response arrives in the browser, the JavaScript program receives an "asynchronous" notification, so that it can be processed or displayed appropriately.


Ajax 技术事实上描述起来非常简单。一般来说,网络程序员将一个链接,按钮,或者网页上用户界面元素的其它类型,连接到JavaScript程序中。当用户激活了界面(点击链接,拖动鼠标,等等),JavaScript程序向网络服务器上的一个URL发送了一些信息或者一个数据请求。然后,网络服务器上的一个程序(可能是由网络程序员设计的)处理这个请求并且返回一个响应或者一些数据。一般来说,数据是XML格式的,但是这种格式并不是必须的。当数据或者响应到达浏览器的时候,JavaScript程序收到了一个"异步" 通知,这样,程序就可以适当地处理和显示了。

Today, Ajax is supported in some form by most visual web browsers (though only if the user has JavaScript turned on). Of course, like most complex JavaScript, there are differences between how browsers implement JavaScript. However, these are not too difficult to overcome. The only real restriction on Ajax is that the URL you send the information to has to be on the same web site as the URL the JavaScript came from. Other than that, the uses for the technology are only limited to what you can figure out how to program.

如今, Ajax有大多数可视网络浏览器提供(但是只有偶用户打开JavaScript才可以)。当然,与大多数复杂的JavaScript类似,浏览器执行JavaScript的方式会有所不同。 但是,这并不是很难克服的困难。Ajax上唯一的限制因素是你将信息发送到的URL必须与JavaScript来自的站点URL的在同一个站点上。除了这个以外,技术的使用只会取决你,你是否知道怎样编程。

Ajax in WordPress

WordPress中的Ajax

Because of its responsiveness, Ajax technology is being adopted by all sorts of web sites -- and WordPress is no exception. Currently, the core of WordPress uses Ajax only in the administration screens. For instance, Ajax is used for instant updates when you are doing comment moderation, and when you are adding and deleting items from lists such as categories, blogroll, and posts; Ajax is also the technology behind the auto-save functionality on post and page editing screens. Several themes and plugins also use Ajax; for instance, some post rating plugins use Ajax to store the visitor's rating in the database and then display an updated average rating.

因为Ajax具有的响应性,Ajax技术有各种各样的网站所使用-- WordPress 也不例外。当前,WordPress的核心只会在管理界面上使用Ajax。例如,当你在审核评论或者当你在添加或者删除列表上的一些内容,如类别,友情链接,和文章的时候,Ajax就被用来立即更新;Ajax也是文章和网页编辑界面自动保存功能后的一种技术。几个主题和插件也使用Ajax;例如,一些文章给插件分级使用Ajax 来在数据库储存中访客的等级级别然后显示一个更新了的平均的等级级别。

Further Reading

深入阅读

General Information

一般的信息



Developer Information

开发者的信息


A collection thanks to User:Jalenack's "Using Ajax":




A collection 感谢 User:Jalenack的 "使用Ajax":

* 简化的 Ajax - SAJAX




Generally Speaking

一般而言