我正在使用sencha touch应用程序,需要每1分钟向服务器发送一次请求.我正在使用setInterval()& setTimeOut()均可在台式机上使用Chrome浏览器,但在iPhone或Android上则无法使用(它们不会被调用)
有没有人(成功地)使用过这些功能,或者是否有其他功能要使用.
使用的代码
setInterval(function(){ //server calling method },10000); setTimeout(function name,10000);
函数名称是具有代码以将请求发送到服务器的函数.
谢谢
解决方法:
您为什么不为此目的选择Sencha的DelayedTask类?将会是这样的:
//create the delayed task instance with our callbackvar task = Ext.create('Ext.util.DelayedTask', function() { //server calling method // The task will be called after each 10000 ms task.delay(10000);}, this);//The function will start after 0 milliseconds - so we want to start instantly at firsttask.delay(0);//to stop the task, just call the cancel method//task.cancel();
而且,我在Phonegap上使用了此代码,并且效果很好.
总结以上是内存溢出为你收集整理的sencha中的setTimer()和timeInterval()在Android和iPhone设备中不起作用全部内容,希望文章能够帮你解决sencha中的setTimer()和timeInterval()在Android和iPhone设备中不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)