jquery progressbar ajax,javascript - jQuery AJAX loop to refresh jQueryUI ProgressBar - Stack Overfl...

I've got a jQueryUI progressbar that should show the percentage of a query done. Oracle has a nice system table that lets you see operations that will take more than 10 seconds. I'm trying to make staggered $.ajax calls to this query in order to refresh the progress bar.

Problem is, I can either get the loops to make rapid-fire requests without any wait time, or just delay the entire JavaScript from executing.

I start the first request by clicking my "Execute" button in a jQueryUI dialog.

$("#dlgQuery").dialog({

buttons: {

Execute: function () {

$(this).dialog("close");

StartLoop();

}

}

});

I'm trying to build either the StartLoop() function or make a recursive GetProgress() function. Ideally, I will have a public variable var isDone = false to act as my indicator for when to terminate the loop or stop recursively calling the function.

For simplicity I have just made a static loop that executes 100 times:

function StartLoop(){

for (var i = 0; i < 100; i++) {

GetProgress();

}

}

And here's my sample ajax request:

function GetProgress() {

$.ajax({

url: "query.aspx/GetProgress",

success: function (msg) {

var data = $.parseJSON(msg.d);

$("#pbrQuery").progressbar("value", data.value);

//recursive?

//GetProgress();

//if (data.value == 100) isDone = true;

}

});

}

So what I've found is, so far:

setTimeout(GetProgress(), 3000) in StartLoop() freezes Javascript, and the dialog does not close (I assume, because it will wait until the query is done).

This one, pausecomp(3000) does much the same thing.

If I call either of these in the "success" function of my AJAX request, it gets ignored (probably because it's starting another call asynchronously).

I'm kinda stuck here, any help would be appreciated, thanks.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值