0

i have these two functions:

1.the first one

      someFunction = function(objectname){
      var vidobject = objectname;
      setInterval( function() { interfunc(vidobject); }, 500 );

};

which gets an object from a button click.

2.And the second one which i want to use with the inverval:

interfunc(obje){

alert(obje)

});

but when the alert comes up it writes "undefined" and if il use for example vidobject.id it wont event alert and if i alert the object in the first function it alerts succefully any solutions? :)

1 Answers1

0

Why do you calling setInterval inside setInterval?

Just alert in first setInterval's callback as you said.

UPDATE

It seems the object is cleared somewhere when your interval callback is called.

Try to have clone object before setInterval.

To copy an object check this.

Or if you just need some value from object, just keep the value from the object.

someFunction = function(objectname){
  var vidobjectID = objectname.id;
  setInterval( function() { interfunc(vidobjectID); }, 500 );
};
Community
  • 1
  • 1
dongseok0
  • 737
  • 2
  • 7
  • 18