I am using php and MySQL to insert 50k data at a time within loop, i want to show progress bar which display number of record inserted like 1000 record inserted,2000 record inserted,5000 record inserted like this. I am trying this code. but its not working. Please help anyone.
/////////////////progressbar.php///////////////////
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<script>
function prbar(){
$("#pr").load("getSession.php");
tmout=setTimeout(prbar,2000);
}
$.ajax({
url:"ajax.php",
type:'get',
datatype:'json',
data:"st=str",
success:function(data){
clearTimeout(tmout);
alert(data);
},
error:function(){
alert("error");
}
});
prbar();
</script>
<html>
<body>
<div id="pr"> Processing.... </div>
</body>
</html>
////////////// ajax.php/////////////////
session_start();
for($i=1;$i<=50000;$i++){
mysql_insert("")// insert query
$_SESSION['vl']=$i;
session_write_close();
}
?>
//////////////getSession.php/////////////////
<?php
session_start();
echo "$_SESSION[vl] Number Inserted !";
?>