[請益] 請教javascript recursive問題
我是PHP和javascript新手,有個function的問題想請教大家
下面是function的程式碼
請問這樣寫會造成記憶體無限長大嗎?
還是在最後一行setTimeout()一執行後,本身就會結束,
不用等setTimeout()裡面的function return?
謝謝!
function printLog(s_flag)
{
if(start==0 && s_flag) return;
$.ajax
({
url : timeLogUrl,
type : "GET",
data : { 'read':'on' },
async : true,
})
.success(function( data )
{
data = JSON.parse(data);
$("#log").empty();
for( var ii = 0; ii<data.length;ii++)
{
$newdiv = $( "<div>"+data[ii]+"</div>" )
$("#log").append($newdiv);
}
delete data;
if(s_flag)
setTimeout("printLog("+true+")",3000);
//return;
});
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.134.107.156
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1453954586.A.547.html
推
01/28 15:00, , 1F
01/28 15:00, 1F
→
01/28 16:56, , 2F
01/28 16:56, 2F