脚本运行时加载栏 [英] Loading bar while script runs

查看:103
本文介绍了脚本运行时加载栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php脚本,要运行大约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 done load the page the user is on...has anybody any ideas how I can do this? Thanks

推荐答案

首先,您需要使用Ajax请求来调用脚本.所有jQuery ajax方法都提供函数回调,该函数回调在调用完成时被调用.您可以在提出请求时显示进度条,并在完成后将其隐藏:

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();
});

您还可以使用 BlockUI 之类的插件.

You could also use a plug-in like BlockUI.

这篇关于脚本运行时加载栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆