日期:2014-05-16  浏览次数:20630 次

对ajax的理解.
  开源网站 http://www.open-open.com/67.htm
ajax即异步javascript和XML.网页上使用ajax比较多的技术是表单无刷新的技术。我们来看看这个原理.

   XMLHttpRequest与服务器直接通信和返回
{从 Web 表单中获取需要的数据。
建立要连接的 URL。
打开到服务器的连接。
设置服务器在完成后要运行的函数。
发送请求。}
  xmlHttpRequest
open():建立到服务器的新请求。
send():向服务器发送请求。
abort():退出当前请求。
readyState:提供当前 HTML 的就绪状态。
responseText:服务器返回的请求响应文本。

http://www.ibm.com/developerworks/cn/xml/wa-ajaxintro6/

清单 1. 一个简单的 Google 搜索应用程序的 HTML 代码

<html>
<head>
  <title>My Google AJAX Search API Application</title>
  <link href="http://www.google.com/uds/css/gsearch.css"
        type="text/css" rel="stylesheet" />
  <script
        src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=
YOUR KEY HERE
"
        type="text/javascript"> </script>
  <script language="Javascript" type="text/javascript">
    function OnLoad() {
      // Create the Google search control
      var searchControl = new GSearchControl();

      // These allow you to customize what appears in the search results              
      var localSearch = new GlocalSearch();                                    
      searchControl.addSearcher(localSearch);                                  
      searchControl.addSearcher(new GwebSearch());                             
      searchControl.addSearcher(new GvideoSearch());                           
      searchControl.addSearcher(new GblogSearch());                            

      // Tell Google your location to base searches around                     
      localSearch.setCenterPoint("Dallas, TX");

      // "Draw" the control on the HTML form
      searchControl.draw(document.getElementById("searchcontrol"));
    }
  </script>
</head>

<body onload="OnLoad()">
  <div id="searchcontrol" />
</body>
</html>


JQuery 自定义动画
jQuery 函数创建自定义动画的语法:
$(selector).animate({params},[duration],[easing],[callback])
关键的参数是 params。它定义产生动画的 CSS 属性。可以同时设置多个此类属性:
animate({width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"});
第二个参数是 duration。它定义用来应用到动画的时间。它设置的值是:"slow", "fast", "normal" 或毫秒。
实例 1
<script type="text/javascript">
$(document).ready(function(){
$("#start").click(function(){