2017-06-14 29 views
-2

我有以下功能:

<script> 
      $(document).ready(function() { 
       $("#campo_aeroporto").autocomplete({ 
        source: function (request, response) { 
         $.ajax({ 
          type: "GET", 
          url: "aeroportos.php", 
          data: { 
           q: request.term 
          }, 
          success: function (data) { 
           response(data); 
          } 
         }) 
        }, 
        minLength: 2 
       }); 
      }); 
     </script> 

但控制檯一直指責遺漏的類型錯誤:$不是一個函數,我已經使用的,而不是$ jQuery的tryed和有沒有運氣...

+3

是jQuery的被包括在內? – j08691

回答

0

嘗試沒有衝突包裝:

(function($){ 
$(document).ready(function() { 
    $("#campo_aeroporto").autocomplete({ 
     source: function (request, response) { 
      $.ajax({ 
       type: "GET", 
       url: "aeroportos.php", 
       data: { 
        q: request.term 
       }, 
       success: function (data) { 
        response(data); 
       } 
      }) 
     }, 
     minLength: 2 
    }); 
}); 
})(jQuery); 
+0

仍然不能工作:( –

相關問題