什么是 AJAX 库 API?

来源:岁月联盟 编辑:zhuzhu 时间:2009-12-18
AJAX 库 API 是一种内容分布网络,可载入最受欢迎的开源 JavaScript 库的架构。通过使用 Google AJAX API 载入程序的 google.load() 方法,您的应用程序能够迅速从全球任何位置访问不断增长的、最受欢迎的开源 JavaScript 库列表,包括:

jQuery
jQuery UI
Prototype
script.aculo.us
MooTools
Dojo
SWFObject
Yahoo! 用户界面库 (YUI) Google 直接与关键相关人员配合来维护每个库的利益,并在最新稳定版本发布时接受这些版本。一旦我们托管给定库的版本,我们承诺无限期地托管该版本。
AJAX 库 API 在使用库集合的同时消除了用 JavaScript 开发混搭的不便之处。我们消除了托管库的不便之处、正确地设置缓存标头、与最新错误修正日期保持一致等。

<script src="http://www.google.com/jsapi"></script>
<script>
  // Load jQuery
  google.load("jquery", "1");

  // on page load complete, fire off a jQuery json-p query
  // against Google web search
  google.setOnLoadCallback(function() {
    $.getJSON("http://ajax.googleapis.com/ajax/services/search/web?q=google&v=1.0&callback=?",

      // on search completion, process the results
      function (data) {
        if (data.responseData.results &&
            data.responseData.results.length > 0) {
          var results = data.responseData.results;
           
          for (var i=0; i < results.length; i++) {
            // Display each result however you wish
            alert(results[i].titleNoFormatting);
          }     
        }
         
      });
    });
</script>

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wjlwjlwjlwjl/archive/2009/12/18/5029582.aspx