posts - 5,  comments - 1,  trackbacks - 0

加载页面时给提示:
这是要导入的js:
/*
url-loading object and a request queue built on top of it
*/

/* namespacing object */
var net=new Object();

net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;

/*--- content loader object for cross-browser requests ---*/
net.ContentLoader=function(url,onload,onerror,method,params,contentType){
  this.req=null;
  this.onload=onload;
  this.onerror=(onerror) ? onerror : this.defaultError;
  this.loadXMLDoc(url,method,params,contentType);
}

net.ContentLoader.prototype.loadXMLDoc=function(url,method,params,contentType){

  if (!method){
    method="GET";
  }
  if (!contentType && method=="POST"){
    contentType='application/x-www-form-urlencoded;charset=UTF-8';
  }
  if (window.XMLHttpRequest){
    this.req=new XMLHttpRequest();
  } else if (window.ActiveXObject){
    this.req=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (this.req){
    try{
      var loader=this;
      this.req.onreadystatechange=function(){
        net.ContentLoader.onReadyState.call(loader);
      }
      this.req.open(method,url,true);
      if (contentType){
        this.req.setRequestHeader('Content-Type', contentType);
      }
      this.req.send(params);
    }catch (err){
      this.onerror.call(this);
    }
  }
}


net.ContentLoader.onReadyState=function(){
  var req=this.req;
  var ready=req.readyState;
  if (ready==net.READY_STATE_COMPLETE){
    var httpStatus=req.status;
    if (httpStatus==200 || httpStatus==0){
      this.onload.call(this);
    }else{
      this.onerror.call(this);
    }
  }
}

net.ContentLoader.prototype.defaultError=function(){
  alert("error fetching data!"
    +"\n\nreadyState:"+this.req.readyState
    +"\nstatus: "+this.req.status
    +"\nheaders: "+this.req.getAllResponseHeaders());
}

-----------------------------分隔线---------------------------------
然后在页面里加一个层<div id="repositorylcontent">正在加载相关信息。。。请稍候。。。</div>
位置:放在加载费时的地方
写几个function

<script event="onload" for="window">
displayRepositorylName();
     displayRepositorylcontent();
     displayNews();
     displayService();
</script>
<script>
        var request=false;

        function displayRepositorylName(){
          var serviceUrl = serverUrl+"repositoryldetailservlet?command=displayRepositorylName&repositorylid=72";
          var params = "";
          new net.ContentLoader(serviceUrl,showdisplayRepositorylName,null,"GET",params,null);
 }
 function showdisplayRepositorylName(){
          var data=this.req.responseText;
          repositorylname.innerHTML=data;
 }
 function displayRepositorylcontent(){
          var serviceUrl = serverUrl+"repositorylservlet?command=queryonerepositoryl&repositorylid=72";
          var params = "";
//          alert(serviceUrl);
          new net.ContentLoader(serviceUrl,showRepositorylcontent,null,"GET",params,null);
 }
 function showRepositorylcontent(){
          var data=this.req.responseText;
          repositorylcontent.innerHTML=data;
 }
//news
        function displayNews(){
          var serviceUrl = serverUrl+"newsservlet?command=doquery&displaynum=2";
          var params = "";
          new net.ContentLoader(serviceUrl,getNewsData,null,"GET",params,null);
 }
 function getNewsData(){
          var data3=this.req.responseText;
          news.innerHTML=data3;
 }
        //
        function displayService(){
          var serviceUrl = serverUrl+"serviceservlet?command=doquery&displaynum=4";
          var params = "";
          new net.ContentLoader(serviceUrl,getServiceData,null,"GET",params,null);
 }
 function getServiceData(){
          var data5=this.req.responseText;
          service.innerHTML=data5;
 }
 //add to the stroe
 function addStore(){
  var serviceUrl = serverUrl+"repositoryldetailservlet?command=addStore&repositorylid=72";
          var params = "";
          new net.ContentLoader(serviceUrl,showAddStore,null,"GET",params,null);
 }

posted on 2006-08-14 16:28 herry 阅读(455) 评论(0)  编辑  收藏 所属分类: JavaScript

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

有空多联系~

常用链接

留言簿(3)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

java

搜索

  •  

最新评论

阅读排行榜

评论排行榜