Question about the php Data update progress. This post was last edited by aier520 at 00:59:45, January 6 ,.
The update. php page is roughly as follows:
// The execution time of this page is relatively long, which may take several minutes $ SQL = "select * from news "; // run the SQL statement to obtain the array $ news_arr. the specific code is omitted. $ news_count = count ($ news_arr)-1. the number of arrays is counted, to calculate the update progress // start the loop array and update the data foreach ($ news_arr as $ key => $ value) {// obtain the data from another database and update it to the local data, code omitted $ _ SERVER ['wait'] = floor ($ key/$ news_count * 100); save the update progress to the session}
The getdata. php page is the update progress saved in the output session. the code is as follows:
echo $_SERVER['wait'];
The html page is roughly as follows:
When you click this button, a js (written by jquery) is triggered)
$ (". Bgn ,. bgy "). click (function () {url = "http: // localhost/update. php "; // data update operation page $. get (url); // use ajax to execute the update program function getwait () {$. get ("http: // localhost/getdata. php ", // obtain the data update progress function (redata) {// The problem lies in the above $. get (url) to execute the update, // if the php update script is not completed (that is, update. the php program on this page is not executed), // no data is returned here. may I ask my friends, how can I solve this problem? Alert (redata); // update progress bar processing}, "text")} setInterval (getwait, 1000 );})
Reply to discussion (solution)
You need to make a progress bar and make a timer at the front end to submit the data and return the result to submit 10% at a time... you don't have to say that.
PHP progress bar