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
Add a ment  | 

1 Answer 1

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