21,886
社区成员
发帖
与我相关
我的任务
分享
function get_feed(m_time){
if(!arguments[0]) m_time = "Not";
$.ajax({
url:'modules/douban/feedback.php',
data:{'action':'getfeed','m_time':m_time},
type:"POST",
dataType:'json',
//contentType: 'application/json; charset=utf-8',
cache:'false',
//async: true,
success:function(data){
m_time=data.m_time;//修改时间
if(typeof(data.process)=='undefined'){
var process_time='empty';
} else {
var last_time=m_time;
$.each(data.process,function(i,item){
var process_time=item.time;
var each_process=item.str;
if(each_process.length>0){
$("#processing").append(process_time+':'+each_process);
}
});
each_process=null;
}
if(process_time=='end_time'){
$.post('modules/douban/feedback.php',{action:'del_file'});
window.clearInterval(repeat);
} else {
repeat=window.setInterval(function(){get_feed(m_time);},30000);
}
},
complete:function(xhr,ts){//无论成功与否均会执行
//alert(ts);
},
error:function(xhr){alert('发生了错误!');}
});
}
,我用这个js用来请求后台处理进度(文本文件中),进度每次更新后会覆盖原来的内容,使用修改时间判断进度是否已更新。第一次(文本文件为空)执行没问题,当进度更新时,就出错,这个请求次数会以几何倍数增加,过不了多久浏览器就崩溃了。不知道哪里写错了?