Filling jQuery Progress Bar with results from an external php file -
i calling 2 php files throw jquery , ajax. have progress bar @ same page , need fill respect results of 2 files. example increase 10% after every function executed.
progress bar in main php file
<meta charset="utf-8"> <script> $(function() { $( "#progressbar" ).progressbar({ value: 80 }); }); </script> <div class="demo"> <div id="progressbar"></div> </div>
javascript calls external php files
$.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; } } });
external php file 2-release-temp.php
<?php /* * script 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 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"; ?>
this not possible, split php file , call each 1 of them. after result of 1 php file can increase progress bar.
each call this:
// 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) } });
your 2 php files this:
buildfacetespath.php
<?php /* * script 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 facets */ $res = $adb->buildfacetspath(); if (!$res) { print $adb->error; exit; } ?>
buildclassification.php
<?php /* * script 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"; ?>
Comments
Post a Comment