我有一个实时搜索ajax和即时获取控制台日志错误Uncaught Typeerror: undefined is not a function.
该错误指向我的代码的第一行。我以前用过这个,它不知道现在发生了什么,有什么想法?jQuery生活问题 - undefined不是函数
$("input#search-staff").live("keyup", function() {
// Set Search String
var staffname = $(this).val();
// Do Search
if(staffname !== ''){
$.ajax({
type: "GET",
url: "_ajax/_tasks/search-staff.php",
data: { query: staffname },
cache: false,
success: function(html){
$("ul#staff-list").html(html);
}
});
}return false;
});
您确定DOM中存在'$(“input#search-staff”)元素吗? – eithed 2014-09-01 16:53:51
[.live](http://api.jquery.com/live/)已弃用。考虑使用[事件委托](http://learn.jquery.com/events/event-delegation/)而不是 – Stryner 2014-09-01 16:54:49
它在dom中存在 – user934902 2014-09-01 16:55:23