Last active
April 12, 2018 11:35
-
-
Save Nor1m/9523e4af1ef47d3d3d5df58d207ea16b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//PHP | |
function getProgressAction(){ | |
session_start(); | |
echo isset($_SESSION['percent']) ? $_SESSION['percent'] : ''; | |
exit(); | |
} | |
public function getProgress($max, $progress, $text="Загрузка: "){ | |
if(!$progress) $progress = 1; | |
if(!$max) $progress = 1; | |
$percent = round( ( $progress / $max ) * 100 ); | |
if( $percent > 100 ) $percent = 99; | |
@ob_start(); | |
session_start(); | |
$_SESSION['percent'] = $text ."<b>". $percent ."</b>"; | |
session_write_close(); | |
} | |
//JS | |
function getProgress() { | |
$.ajax({ | |
type: 'POST', | |
url: '/index/getProgress/', | |
success: function(data) { | |
progress_bar(data); | |
}, | |
}); | |
return false; | |
} | |
var myVar = setInterval(function() { | |
getProgress(); | |
}, 300); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment