PHP to get Data update progress issues

Source: Internet
Author: User
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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.