开发者

Loading bar while script runs

开发者 https://www.devze.com 2023-02-16 05:10 出处:网络
I have a php script which takes about 10 seconds to run because it is pulling in data and storing it in the db, I want to display a loading bar whilst this script is running and then once its don开发者

I have a php script which takes about 10 seconds to run because it is pulling in data and storing it in the db, I want to display a loading bar whilst this script is running and then once its don开发者_如何学Ce load the page the user is on...has anybody any ideas how I can do this? Thanks


At first you need to call the script using an Ajax request. All jQuery ajax methods offer function callbacks that are called when the call is completed. You can show the progress bar when you make the request and hide it, when it is finished:

$("#MyProgressBar").show();
$("#placeholder").load(myurl, function() {
  $("#MyProgressBar").hide();
});

You could also use a plug-in like BlockUI.

0

精彩评论

暂无评论...
验证码 换一张
取 消