PHP to get Data update progress issues
This post was last edited by aier520 on 2013-12-06 00:59:45
The update.php page is probably as follows:
This page takes a long time to execute and may take a few minutes
$sql = "SELECT * FROM News";
Execute SQL get array $news _arr specific code omitted
$news _count=count ($news _arr)-1; count the number of arrays in order to calculate the progress of the update
Start loop array and update data
foreach ($news _arr as $key = + $value) {
To get data from a database and update it to local data, the code is omitted
$_server[' Wait ']=floor ($key/$news _count*100); Save the update progress in session
}
getdata.php page is the update progress saved in the output session, the code is as follows
echo $_server[' wait '];
The contents of the HTML page are as follows:
Triggers a JS (jquery-written) When this button is clicked
$ (". Bgn,.bgy"). Click (function () {
Url= "http://localhost/update.php";//action page for data update
$.get (URL);//Use AJAX methods to execute the update program
function getwait () {
$.get (
"http://localhost/getdata.php",//Get the progress of data update
function (Redata) {
The problem is here in the above $.get (URL) to perform the update,
If the PHP update script does not complete (that is, the program that update.php this page does not complete),
There will be no data to return, please, friends, how can i solve this problem?
alert (redata);
Here to do the update progress bar processing
},
"Text")
}
SetInterval (getwait, 1000);
})
Share to: more
------Solution--------------------
You have to do a progress bar at the front-end to do a timer timed to submit the data to submit the results submitted once 10% ... No, I'm telling you, that's what it means.