admin管理员组文章数量:1425717
I'm using jQuery 1.9.1 and trying to have an ajax query which is called every 5 seconds and updates some content.
Using the code below, I get the following error in Chrome's console:
Uncaught TypeError: Object #<Object> has no method 'apply'
The line the error is on is line 3 of jquery.min.js
$(document).ready(function(){
function getData()
{
$.getJSON('/ajax/pull', function(data){
console.log(data.items);
$("span").each(data.items, function(items){
console.log(items);
if($(this).attr('id') in items)
{
console.log('here');
}
});
});
}
window.setInterval(function() { getData(); } , 5000);
});
I've looked through the other questions which have the same problem, but trying those fixes has no affect on my problem.
I'm using jQuery 1.9.1 and trying to have an ajax query which is called every 5 seconds and updates some content.
Using the code below, I get the following error in Chrome's console:
Uncaught TypeError: Object #<Object> has no method 'apply'
The line the error is on is line 3 of jquery.min.js
$(document).ready(function(){
function getData()
{
$.getJSON('/ajax/pull', function(data){
console.log(data.items);
$("span").each(data.items, function(items){
console.log(items);
if($(this).attr('id') in items)
{
console.log('here');
}
});
});
}
window.setInterval(function() { getData(); } , 5000);
});
I've looked through the other questions which have the same problem, but trying those fixes has no affect on my problem.
Share Improve this question edited Mar 9, 2013 at 23:14 penguin asked Mar 9, 2013 at 23:05 penguinpenguin 8763 gold badges14 silver badges30 bronze badges 1- Just added those two semicolons (and updated the code here) but I still get the same error. – penguin Commented Mar 9, 2013 at 23:15
1 Answer
Reset to default 5.each() takes only 1 argument which is a function not an array.
本文标签: javascriptjQuery Uncaught TypeError Object ltObjectgt has no method 39apply39Stack Overflow
版权声明:本文标题:javascript - jQuery: Uncaught TypeError: Object #<Object> has no method 'apply' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745383070a2656255.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论