每5秒刷新一次javascript代码浏览器崩溃
我需要每5秒读取一次json,我还有10次,每60次以上。过了一会儿,浏览器崩溃了每5秒刷新一次javascript代码浏览器崩溃,javascript,browser,crash,Javascript,Browser,Crash,我需要每5秒读取一次json,我还有10次,每60次以上。过了一会儿,浏览器崩溃了 var Clock = { seconds: 1, start: function () { var that = this; var aradios=[], acoches=[], velcoches=[],nradios=[], ncoches=[]; this.interval = setInte
var Clock = {
seconds: 1,
start: function () {
var that = this;
var aradios=[], acoches=[], velcoches=[],nradios=[], ncoches=[];
this.interval = setInterval(function () {
// leo todos los radios y su posicion
$.getJSON("radiosenmaparemain.php", function(data){
for (var i = 0, len = data.length; i < len; i++) {
var posradio = new google.maps.LatLng(data[i].lat, data[i].lon);
aradios.push(posradio);
nradios.push(data[i].idcolaborador);
}
});
// leo todos los coches y su posicion
$.getJSON("todosenmapa.php", function(data2){
for (var n = 0, len = data2.length; n < len; n++) {
var poscoche = new google.maps.LatLng(data2[n].lat, data2[n].lon);
acoches.push(poscoche);
ncoches.push(data2[n].idpiloto);
velcoches.push(data2[n].vel);
}
});
for(var i in acoches){
for(var n in aradios){
// alert(n + " " + i);
var distancia = google.maps.geometry.spherical.computeDistanceBetween(acoches[i],aradios[n]);
var cdistancia=distancia.toString();
var li = cdistancia.lastIndexOf(".");
cdistancia=cdistancia.substr(0,li);
var span=(parseInt(ncoches[i]))+'-'+(parseInt(nradios[n]));
$('#km-'+span).text(cdistancia+" m");
$('#tm-'+span).text(calculasegundos(distancia/velcoches[i]));
// alert('#km-'+span);
}
}
}, 10000)
},
pause: function() {
clearInterval(this.interval); delete this.interval;
},
resume: function() {
if(!this.interval) this.start();
}
}
var-Clock={
秒:1,
开始:函数(){
var=这个;
var aradios=[]、acoches=[]、velcoches=[]、nradios=[]、ncoches=[];
this.interval=setInterval(函数(){
//leo todos los Radio y su Position
$.getJSON(“radiosenmaparemain.php”,函数(数据){
对于(变量i=0,len=data.length;i
请修改代码声明Shello,我不明白你的答案,除了我是新来的,我是西班牙人。你可以把它清理掉。非常感谢。