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!