What is the best way of showing progress on an Ajax call?

前端 未结 12 1079
遥遥无期
遥遥无期 2020-11-28 05:17

I have an Ajax call that updates 5,000 records in a database so this takes a lot of time. I have an Ajax \"Loading image\" showing that something is happening, but I am loo

12条回答
  •  悲&欢浪女
    2020-11-28 05:24

    I just got an idea while reading the replies.

    JavaScript and PHP share cookies,

    1. Create a cookie with JavaScript when an Ajax call is made.
    2. In an Ajax PHP file increment the value in that cookie with each SQL update.
    3. In JavaScript a recursive function will read that particular cookie and will update progress bar numbers.

    Advantages:

    1. Only 1 Ajax call.
    2. Less load on the server.

提交回复
热议问题