我正在调用两个php文件抛出jQuery和ajax。我在同一页面上有一个进度条,我需要填写这两个文件的结果。例如,在执行每个函数后增加10%。
主要php文件中的进度条
<meta charset="utf-8">
<script>
$(function() {
$( "#progressbar" ).progressbar({
value: 80
});
});
</script>
<div class="demo">
<div id="progressbar"></div>
</div>
调用外部php文件的Javascript
$.ajax({
// url: 'ajax/releaseBackEnd.php',
url: 'batch/2-release-tmp.php',
type: 'POST',
async: false,
data: {"fId":"abc"},
dataType: 'xml',
error: function(){
alert('Error loading XML document1');
},
success: function(data){
//check error
alert("success1");
var $error=$(data).find('error1').text();
if($error!="0")
{
messageBox("Error1",$error);
return;
}
}
});
外部PHP文件2-release-temp.php
<?php
/*
* script for releasing classification
*/
require_once(dirname(__FILE__) . "/../config.php");
require_once(TU_CLA_LIB . "/Database.php");
/* database */
$error = "";
$aDb = new Database();
if ($aDb->error) {
print $aDb->error;
exit;
}
/* build pathFacetsInfo for facets */
$res = $aDb->buildFacetsPath();
if (!$res) {
print $aDb->error;
exit;
}
/* build classification */
$res = $aDb->buildClassification();
if (!$res) {
print $aDb->error;
exit;
}
print "release succeed.\n";
?>
答案 0 :(得分:0)
这是不可能的,你可以分割你的php文件并调用它们中的每一个。在一个php文件的结果之后,您可以增加进度条。
每次通话都可能如下所示:
// buildFacetesPath.php
$.ajax({
url: 'batch/buildFacetsPath.php',
success: function(data){
var old = $("#progressbar").progressbar("value");
$("#progressbar").progressbar("value", old+10)
}
});
// buildClassification.php
$.ajax({
url: 'batch/buildClassification.php',
success: function(data){
var old = $("#progressbar").progressbar("value");
$("#progressbar").progressbar("value", old+10)
}
});
你的两个php文件可能如下所示:
<强> buildFacetesPath.php 强>
<?php
/*
* script for releasing classification
*/
require_once(dirname(__FILE__) . "/../config.php");
require_once(TU_CLA_LIB . "/Database.php");
/* database */
$error = "";
$aDb = new Database();
if ($aDb->error) {
print $aDb->error;
exit;
}
/* build pathFacetsInfo for facets */
$res = $aDb->buildFacetsPath();
if (!$res) {
print $aDb->error;
exit;
}
?>
<强> buildClassification.php 强>
<?php
/*
* script for releasing classification
*/
require_once(dirname(__FILE__) . "/../config.php");
require_once(TU_CLA_LIB . "/Database.php");
/* database */
$error = "";
$aDb = new Database();
if ($aDb->error) {
print $aDb->error;
exit;
}
/* build classification */
$res = $aDb->buildClassification();
if (!$res) {
print $aDb->error;
exit;
}
print "release succeed.\n";
?>