在jQuery ajax中延迟加载数据2秒

inp*_*put 4 ajax search jquery delay

我正在通过jQuery ajax在div容器中加载搜索结果.我想在2秒延迟后或用户在文本框中输入至少3个字母/字符进行搜索后向用户显示结果.我该怎么做?

jQuery代码:

$(".bsearch").keydown(function() {
  //create post data
  var postData = { 
    "search" : $(this).val()
  };

  //make the call
  $.ajax({
    type: "POST",
    url: "quotes_in.php",
    data: postData, 
    success: function(response){
      $("#left").html(response);                    
      $("div#smore").hide();
    }
  });
Run Code Online (Sandbox Code Playgroud)

med*_*iev 11

使用此功能:

setTimeout(function() {
    $('#left').html(response);
}, 2000);
Run Code Online (Sandbox Code Playgroud)