案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/js/jquery.js"></script>
4
<script type="text/javascript">
5
$(document).ready(function(){
6
  $("button").click(function(){
7
    $("div").load("wrongname.xml",function(response,status,xhr){
8
      if (status=="success")
9
      {
10
      $("div").html("<ol></ol>");
11
      $(response).find("artist").each(function(){
12
        var item_text = $(this).text();
13
        $('<li></li>').html(item_text).appendTo('ol');
14
        });
15
      }
16
      else
17
      {
18
      $("div").html("An error occured: <br/>" + xhr.status + " " + xhr.statusText)
19
      }
20
    });
21
  });
22
});
23
</script>
24
</head>
25
<body>
26
<p>Artists</p>
27
<div></div>
28
<button>获得 CD 信息</button>
29
<p>本例中使用的 XML 文件是 <a href="/example/xmle/cd_catalog.xml" target="_blank">cd_catalog</a></p>
30
</body>
31
</html>
32