Ajax-based loading progress bar and ajax-based loading progress bar

Source: Internet
Author: User

Ajax-based loading progress bar and ajax-based loading progress bar

Ajax beforeSend:

Let's talk about this beforeSend. Execute the command before sending the request to determine whether the user has logged on or not. If the user has not logged on, stop the request and prompt.

$. Ajax ({url: 'My _ action', ype: 'script', beforeSend: function (xhr, opts) {if (1 = 1) // just an example {xhr. abort (); // stop request }}, complete: function () {console. log ('done ');}});

$. Ajax has a parameter complete: function () {} That is executed after the request is complete. With beforeSend, it can be used to display the progress bar.

For example:

$. Ajax ({url: 'My _ action', dataType: 'script', beforeSend: function () {// slowly change the progress bar to 20% to 50%}, complete: function () {// set progress bar to 80%} success: function () {// render page // progress to 100% }});

This is only a progress bar on the surface, showing the approximate progress, not the actual loading progress.

The above is the Ajax implementation loading progress bar introduced by the editor. I hope it will help you. If you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

Related Article

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.