输入请求延时处理

self.searchOldTime = 0;

self.searchDelayTime = 400;

var searchNewTime = new Date().getTime();
    if(searchNewTime-self.searchOldTime < self.searchDelayTime){
     clearTimeout(t);
    }else{
     self.searchOldTime = searchNewTime;
     t = setTimeout(function(){ //延迟0.4S请求
     var _title = $(e.target).closest('input').val();
      self.getPasrentsTaskFromServer(_title);
     },self.searchDelayTime); 
    }

posted @ 2015-01-05 10:59  hlp鹏  阅读(373)  评论(0编辑  收藏  举报