jquery的load()事件和ajax中load()方法的区别

load事件

当图像加载时,改变 div 元素的文本:

$("img").load(function(){
  $("div").text("Image loaded");
});

load(ajax方法)

使用 AJAX 请求来改变 div 元素的文本:

1、$("button").click(function(){
  $("div").load('demo_ajax_load.txt');
});
2、
$("button").click(function(){
    $("div").load("/example/xmle/cd_catalog.xml",function(response,status){
      if (status=="success")
      {
      $("div").html("<ol></ol>");
      $(response).find("artist").each(function(){
        var item_text = $(this).text();
        $('<li></li>').html(item_text).appendTo('ol');
        });
      alert("There are "+$(response).find("cd").size()+" CDs")
      }
    });
posted on 2017-02-14 11:05  2015熊出没  阅读(367)  评论(0编辑  收藏  举报