this.loadXML = function(url, func){
        var me = this;
        var _url = me.baseURL + url +"&"+new Date();
        listURL = _url;
        $.ajax({
            url: _url,
            type: 'GET',
            dataType: 'xml',
            timeout: 100000,
            error: function(){
                alert('加载数据失败!');
            },
            success: function(xml){
     func(xml, me);
/*怎样在此处添加一个提示,提示页面正在加载的字样或者图片*/
            }
        });
    }

解决方案 »

  1.   

    等待图片的代码应该写在外面   不能写在 success函数里  this.loadXML = function(url, func){
    //这里写了可以
      var me = this;
      var _url = me.baseURL + url +"&"+new Date();
      listURL = _url;
      $.ajax({
      url: _url,
      type: 'GET',
      dataType: 'xml',
      timeout: 100000,
      error: function(){
      alert('加载数据失败!');
      },
      success: function(xml){
    func(xml, me);
    /*怎样在此处添加一个提示,提示页面正在加载的字样或者图片*/
      }
      });
      }
      

  2.   


    this.loadXML = function(url, func){
      var me = this;
      var _url = me.baseURL + url +"&"+new Date();
      listURL = _url;
      $.ajax({
      url: _url,
      type: 'GET',
      dataType: 'xml',
      timeout: 100000,
      beforeSend:function(){
        //创建一个提示元素
        var div=document.createElement("div");
       div.style.position="absolute";
       div.style.zIndex=100; 
       div.innerHTML="正在加载...";
       div.style.filter = "alpha(opacity=80)";
       div.style.opacity = 0.8; var clientwidth = document.body.clientWidth;
        var clientheight = document.body.clientHeight;
        var realwidth = (clientwidth>document.body.scrollWidth)?clientwidth:document.body.scrollWidth;
        var realheight = (clientheight>document.body.scrollHeight)?clientheight:document.body.scrollHeight;
        div.style.width = realwidth + "px";
        div.style.height = realheight + "px";
       document.body.appendChild(div);
    },
      error: function(){
      alert('加载数据失败!');
      },
      success: function(xml){
    func(xml, me);
    /*怎样在此处添加一个提示,提示页面正在加载的字样或者图片*/
      }
      });
      }
      

  3.   

    在onload里面打印就行了,加个定时器
      

  4.   

    在返回结果后,需要移除div,在创建div提示时,就给其增加一个id ,如:beforeSend:function(){
        //创建一个提示元素
        var div=document.createElement("div");
       div.setAttribute("id","tipdiv");
       div.style.position="absolute";
       div.style.zIndex=100; 
       div.innerHTML="正在加载...";
       div.style.filter = "alpha(opacity=80)";
       div.style.opacity = 0.8; var clientwidth = document.body.clientWidth;
        var clientheight = document.body.clientHeight;
        var realwidth = (clientwidth>document.body.scrollWidth)?clientwidth:document.body.scrollWidth;
        var realheight = (clientheight>document.body.scrollHeight)?clientheight:document.body.scrollHeight;
        div.style.width = realwidth + "px";
        div.style.height = realheight + "px";
       document.body.appendChild(div);
    },
    //在移除时就可以这样了:
    success:function(xml){
      //这里放你原来的操作
      //移除提示div
      document.body.removeChild(document.getElementById("tipdiv"));
    }