国豹
国豹
  • 发布:2021-03-27 22:09
  • 更新:2021-03-28 01:07
  • 阅读:434

mui.js 背景定位

分类:MUI

小妹用mui.js写了一个每10透过ajax传送坐标的小程式
但这个程式当app在最小化的时候,会传,但一段时间就会停止了,请问这个方式有解吗?

感谢各位大大

function sendTime() {  
    setInterval('getGps()',10000);  
}  
function getGps(){  
    plus.geolocation.getCurrentPosition(translatePoint,function(e){});  
}  
function translatePoint(position){  

                var currentLon = position.coords.longitude; //經度  
                var currentLat = position.coords.latitude;  //緯度  
                var data = deviceToken+"|"+currentLon+"|"+currentLat;  

                mui.ajax(apiserver+'map',{  
                    data:{  
                        data:data  
                    },  
                    dataType:'json',//服務器返回json格式數據  
                    type:'post',//HTTP請求類型  
                    timeout:10000,//超時時間設置為10秒;                
                    success:function(data){  

                    },  
                    error:function(xhr,type,errorThrown){  

                    }  
                });  

            }
2021-03-27 22:09 负责人:无 分享
已邀请:
国豹

国豹 (作者)

目前已查出用 Worker来作另一个线程,可以确保背景执行时不中断

但,目背景执行不能正常载入mui.js 跟 jquery.js

这个部份各位大大有作操作过的经验吗?

importScripts('jq.js','mui.js','mui.min.js');  
onmessage = function(event){  
    console.log(event.data);  
    mui.init();  
}  

该问题目前已经被锁定, 无法添加新回复