How to conflict between Ajax and jquery ready function in asp.net

Source: Internet
Author: User

  asp.net ajax and asp.net are perfectly combined, and it's hard to think of jquery when you find it's not enough. Common jquery and ASP.net ajax are commonly used in conjunction with two things, and if handled well, they don't conflict. But the recent discovery of JQuery's Ready () function in the postback back, ready execution of the action is ineffective, first impression: Will not asp.net Ajax and jqueryd ready conflict, and then remove asp.net ajax script references , and sure enough, everything is fine. After thinking, finally to ASP.net Ajax ScriptManager add a add_endrequest (), jquery ready finally back to normal.

  code is as follows &nbs P;

<script type= "Text/javascript"
    SYS.W EbForms.PageRequestManager.getInstance ()
    add_endrequest (endrequesthandler);
  &NBSP;&NBSP;&NBSP
    function Endrequesthandler (sender, args) {
         if (Args.get_error () == undefined) {
             Pageinit ();
       }
   }

    function Pageinit () {
        $ (document). Ready ( function () {
           //todo 
        });
   }

&NBSP;&NBSP;  pageinit ();  
 </script>

Where, add this code, there are some things to note that if this script is placed in the head, an error occurs, prompting the Sys object undefined, because the asp.net Ajax ScriptManager, is not finished, the Sys object must not be found, At this point the script is placed at the end of the body, everything is normal.

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.