日期:2014-05-16 浏览次数:20559 次
function auction(inid) { var tmpObject = { id : inid, timer1 : null,//用于更新auctioninfo 及修正本地浏览器延时 timer2 : null,//用于状态倒计时 now : null,//服务器now时间戳 ainfo : null,//从服务器获取的ainfo curr_price : 0,//竞拍的当前价 action : null,//喊价纪录 auction_join : null,//参与人 auction_join_t : 0, auction_join_state : false, loadauctioninfo : function() { alert("id:" + this.id); } , init : function(obj) { this.loadauctioninfo(); var self = this; var tmp = '12313'; var o = this this.timer1 = setInterval(function(){o.loadauctioninfo()}, 3 * 1000); } }; return tmpObject; } var aobj = auction(1); aobj.init(aobj);
------解决方案--------------------
this.timer1 = setInterval('self.loadauctioninfo()', 3 * 1000);
this.timer1 = setInterval(self.loadauctioninfo, 3 * 1000);
请查找一下setInterval的用法,第一个参数为函数与字符串的区别