我有以下功能:
<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>
但控制台一直在指责Uncaught TypeError:$不是函数,我已经尝试使用jQuery而不是$并且没有运气......
答案 0 :(得分: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);