Are there progress update events in jQuery ajax?

前端 未结 6 785
北海茫月
北海茫月 2020-12-31 16:22

i have long running task that gets called using jquery ajax. i am using the block ui plugin to show \"loading\". is there anyway i can send progress messages back to the

6条回答
  •  无人及你
    2020-12-31 16:43

    I would have each AJAX request return a JSON response containing a message, the data, and the next URL to request: {message: "Loading second resource...", data: ..., next_url: "/next_part"}

    Before your first AJAX request, set the BlockUI message to "Loading...". When you get the response, set the BlockUI message to the message you get back from your AJAX call. Then make the next AJAX call to the value of "next_url", and so on, looping until you've completed all of the tasks.

    If you're loading one large data set, but in pieces, you may want to do something like a progressive loading design pattern, but also set a progress message as you get each response.

提交回复
热议问题