Trigger Ajaxstart when Ajax starts executing () | Trigger Ajaxstop after Ajax execution ()

Source: Internet
Author: User

"1"

<script type= "Text/javascript" > $ (Function () {$ ("#btnClick"). Click (function () {var id=$ ("#U            Serid "). Val ();            $.get ("Loadhandler.ashx", {Id:id}, function (data, status, JSXHR) {$ ("#loadData"). Text (data);        });        });        The two global events Ajaxstart () and ajaxstop () must be bound to the document element. When the Ajax asynchronous send request, when the network speed is slow, there will be a longer request than the problem, the user and so impatient will close the page. And if you can give the user some hints during the request. For example: trying to load ...        Then the user may wait a little longer and experience a better job.  jquery provides two global events, Ajaxstart () and Ajaxstop (), which trigger the Ajaxstart () event as long as the user triggers Ajax and the request begins (just to prepare to start the request and not complete the request). Ajaxstop () event $ (document) is triggered when the user request ends. Ajaxstart (function () {$ ("#loadMes"). Show ();}).        Ajaxstop (function () {$ ("#loadMes"). Hide (); alert ("Load Complete")});        Of course we can also separate to write $ (document). Ajaxstart (function () {$ ("#loadMes"). Show ()}); $ (document). Ajaxstop (function () {$ ("#loadMes"). Hide (); alert ("Request Complete")}) </script>

When you click the Submit button, the "I'm trying to load ..." is displayed.




Trigger Ajaxstart when Ajax starts executing () | Trigger Ajaxstop after Ajax execution ()

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.