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, To calculate the progress of the update//start loop array and update the data foreach ($news _arr as $key + $value) { //Get data from the database and update to local data, the code omits $_server[' Wait ']= Floor ($key/$news _count*100); Save 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";//Data Update operation page $.get (URL);// Use the Ajax method to execute the Update function getwait () {$.get ("http://localhost/getdata.php"),//Get Data Update progress 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 update.php this page does not complete),//There will not be any data return, I would like to ask friends, how do I solve this problem? alert (redata);//here do update progress bar processing}, "text")}setinterval (getwait, 1000);})
Reply to discussion (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.
PHP progress bar