penguin
penguin

Reputation: 876

jQuery: Uncaught TypeError: Object #<Object> has no method 'apply'

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.

Upvotes: 0

Views: 5290

Answers (1)

Musa
Musa

Reputation: 97672

.each() takes only 1 argument which is a function not an array.

Upvotes: 5

Related Questions