0

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.


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

4

1 に答える 1

5

.each()は、配列ではなく関数である引数を1つだけ取ります。

于 2013-03-09T23:15:32.883 に答える