【发布时间】:2017-05-18 02:41:10
【问题描述】:
我有一个按钮:
<a href="#" onclick="loadPage('admin_manualsend.php?refresh=true'); return false;">
<i class="fa fa-refresh"></i> 1. Refresh Now
</a>
点击它会加载同一个页面,它是一个刷新=true的页面,所以现在当页面加载时会触发:
if(isset($_GET["refresh"]) && $_GET["refresh"]=="true"){
$res = db_query("begin try drop table [TmpTable] end try begin catch end catch");
$res = db_query("SELECT * INTO [TmpTable] FROM [dbo].[ViewLive]");
}
这需要一段时间,我希望它报告 table drop 是否成功,并报告它现在正在传输的记录的计数,然后当它完成时,如下所示:
if(isset($_GET["refresh"]) && $_GET["refresh"]=="true"){
$res = db_query("begin try drop table [TmpTable] end try begin catch end catch");
Show modal, echo 'Drop done'; (or drop failed)
WHILE ( $res = db_query("SELECT * INTO [TmpTable] FROM [dbo].[ViewLive]");
echo 'Count of current record'
count of record +1
)
echo 'Update done';
(user can then close modal)
}
我该怎么做?我使用:PHP、MSSQL、脚本 src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">
谢谢
更新:
function db_query($query) {
global $conn;
$res = sqlsrv_query($conn, $query);
return $res;
}
function db_fetch_array($res) {
$result = array();
while( $array = sqlsrv_fetch_array($res) ) {
$result[count($result)] = $array;
}
sqlsrv_free_stmt($res);
return $result;
}
function db_fetch_row($res) {
$array = sqlsrv_fetch_array($res);
sqlsrv_free_stmt($res);
return $array;
}
function db_fetch_one($res) {
$array = sqlsrv_fetch_array($res);
sqlsrv_free_stmt($res);
return $array[0];
【问题讨论】:
-
loadPage()的代码在哪里? -
@CodeGodie 我不确定你的意思是什么对不起。可能是这个,我在帖子的更新下添加了:)
-
我的意思是你的
a标签中的函数,这里:onclick="loadPage('admin_manualsend.php?refresh=true');正在寻找一个名为loadPage()的JS函数,我想知道那个代码在做什么,你能发布那个函数也一样?