Php 显示一个“;请稍等;文件下载时的消息或进度条
我使用下面的WordPress管理通知来提示用户下载一些文件。我想包括一个进度条或至少一个“下载-请等待”的消息,而文件下载 有什么想法吗 我已经尝试了几种jQuery解决方案,但都没有效果。说到jQuery,我完全是个傻瓜Php 显示一个“;请稍等;文件下载时的消息或进度条,php,jquery,wordpress,download,message,Php,Jquery,Wordpress,Download,Message,我使用下面的WordPress管理通知来提示用户下载一些文件。我想包括一个进度条或至少一个“下载-请等待”的消息,而文件下载 有什么想法吗 我已经尝试了几种jQuery解决方案,但都没有效果。说到jQuery,我完全是个傻瓜 /* Ask user to download GeoIP database files. */ add_action( 'admin_notices', 'lsmi_dl_admin_notice' ); add_action( 'network_admin_notice
/* Ask user to download GeoIP database files. */
add_action( 'admin_notices', 'lsmi_dl_admin_notice' );
add_action( 'network_admin_notices', 'lsmi_dl_admin_notice' ); // also show message on multisite
function lsmi_dl_admin_notice() {
$dir = dirname( __FILE__ );
$localfilev4 = $dir . '/data/GeoIPv4.dat';
$localfilev6 = $dir . '/data/GeoIPv6.dat';
$ctx = stream_context_create( array( 'http' => array( 'timeout' => 120 ) ) );
if ( !file_exists( $localfilev4 ) ) {
if ( current_user_can( 'install_plugins' ) ) {
echo
'<div class="notice notice-warning is-dismissible"><p>Notice: This plugin uses Maxmind Geolite databases for better accuracy. Click the download button to install now.
<form action="" method="get">
<input type="submit" class="button" name="download" value="download" />
</div>';
if($_GET){
if(isset($_GET['download'])){
$newfilev4 = file_get_contents( "https://sourceforge.net/projects/geoipupdate/files/GeoIPv4.dat/download", 0, $ctx );
file_put_contents( $dir . '/data/GeoIPv4.dat', $newfilev4 );
if ( !file_exists( $localfilev6 ) ) {
$newfilev6 = file_get_contents( "https://sourceforge.net/projects/geoipupdate/files/GeoIPv6.dat/download", 0, $ctx );
file_put_contents( $dir . '/data/GeoIPv6.dat', $newfilev6 );
}
}
echo '<meta http-equiv="refresh" content="0">';
}
}
}
}
/*要求用户下载GeoIP数据库文件*/
添加行动(“管理员通知”、“lsmi dl管理员通知”);
添加操作(“网络管理员通知”、“lsmi管理员通知”);//在多站点上也显示消息
函数lsmi_dl_admin_notice(){
$dir=dirname(文件名);
$localfilev4=$dir'/data/geopv4.dat';
$localfilev6=$dir.'/data/geopv6.dat';
$ctx=流\u上下文\u创建(数组('http'=>array('timeout'=>120));
如果(!file_存在($localfilev4)){
如果(当前用户可以(“安装插件”)){
回声
注意:此插件使用Maxmind Geolite数据库以提高准确性。单击下载按钮立即安装。
';
如果($\u GET){
如果(isset($_GET['download'])){
$newfilev4=文件获取内容(“https://sourceforge.net/projects/geoipupdate/files/GeoIPv4.dat/download“,0,$ctx);
文件内容($dir.'/data/geopv4.dat',$newfilev4);
如果(!file_存在($localfilev6)){
$newfilev6=文件获取内容(“https://sourceforge.net/projects/geoipupdate/files/GeoIPv6.dat/download“,0,$ctx);
文件内容($dir.'/data/geopv6.dat',$newfilev6);
}
}
回声';
}
}
}
}
尝试为按钮指定一个ID,如下所示:
<input type="submit" class="button" name="download" value="download" id="download" />
希望这能有所帮助:)尝试给按钮一个ID,如下所示:
<input type="submit" class="button" name="download" value="download" id="download" />
希望这会有所帮助:)工作起来很有魅力。唯一的变化是在顶部添加
jQuery(document).ready(function($){
)。谢谢!没问题,我忘了这很有效。唯一的变化是在顶部添加jQuery(document).ready(function($){
)。谢谢!没问题,我忘了试试这个
$("#download").click(
function () {
$('#download-div').html("Please wait...");
}
);
});