2013-01-25 57 views
0

我在尋找一些能夠過濾結果的東西,因爲用戶不僅僅在用戶點擊現在它是如何工作的字段時輸入結果。我添加了實時和自動完成功能,但這並沒有產生我想要的結果。ajax - onchange事件只在點擊域外時才起作用

任何想法如何讓這個工作?

$(document).ready(function(){ 
    $("form#submit").live('change.autocomplete', function() { 
     // we want to store the values from the form input box, then send via ajax below 
     var thissearch = $('#thissearch').attr('value'); 
     $.ajax({ 
      type: "POST", 
      url: "includes/searchinventorytest.php?", 
      data: "thissearch="+ thissearch, 
      success: function(data){ 
       $('div.success').fadeIn(); 
       $('div.success').html(data); 
      } 
     }); 
     return false; 
    }); 
}); 

回答

1

得到我從Facebook的答案,我想我會分享。我需要「on」和「keyup」

$("form#submit").on('keyup', function() { 
     // we want to store the values from the form input box, then send via ajax below 
     var thissearch = $('#thissearch').attr('value'); 
     $.ajax({ 
     type: "POST", 
     url: "includes/searchinventorytest.php?", 
     data: "thissearch="+ thissearch, 
     success: function(data){ 
     $('div.success').fadeIn(); 
     $('div.success').html(data); 
     } 
     }); 
     return false; 
     }); 
}); 
相關問題