首页 > 代码库 > 输入请求延时处理

输入请求延时处理

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); 
    }

输入请求延时处理