1

我是 Pebble 的新手,我现在正在尝试使用轮询的小程序,这里是部分代码。

main.on('click', 'up', function(e) {
main.body("Now searching...");
var refreshIntervalId = setInterval(function(){ 
ajax({ url: 'http://myipaddress/service', type: 'json' },
function(data, XHRequest){
main.subtitle(data.author);
main.body(data.quote); 
XHRequest.abort();
if(data !== null && data !== undefined && data.author !== '') clearInterval(refreshIntervalId);
},
function(error, XHRequest){
main.title('error');
main.body(error); 
XHRequest.abort();
});
}, 5000);
});

问题是我想退出 setinterval 但我不能使用 clearInterval,因为它没有在 pebble.js 中定义。是否有任何解决方案可以避免使用 clearInterval 退出?还是我以错误的方式使用它?

4

0 回答 0