locked
Sys,loader is undefined RRS feed

  • Question

  • User-389597101 posted

    Hi All 

    I am doing some sample code to understand Sys.loader.registerScript. Here is the code

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
    
    </head>
    <body>
        
        <form id="form1" runat="server">
            <asp:ScriptManager runat="server"></asp:ScriptManager>
            <a href="#">Click Me</a>
        </form>
        <script type="text/javascript">
            function execute() {
                alert("hi");
            }
            $(document).ready(
                function () {                
                    $("a").click(
                        function () {
                            if (window.Sys && Sys.loader) {
                                Sys.loader.registerScript("MyScript", null, execute);
                                alert("Lazy loading");
                            }
                            else {
                                execute();
                            }
                        });
                });
        </script>
    </body>
    </html>
    

    But Sys.loader is undefined. Could you please help

    Monday, September 3, 2018 12:46 PM

Answers

  • User-893317190 posted

    Hi karang,

    You should introduce start.js of microsoft.

    Below is my code.

    <head runat="server">
        <title></title>
        <script src="../Scripts/jquery-3.3.1.js"></script>
           <script src="http://ajax.microsoft.com/ajax/beta/0910/Start.js" ></script>
    </head>
    
    <body>
    
        <form id="form1" runat="server">
                   <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            
          <a href="#">click</a>
     <script type="text/javascript">
         console.log(Sys.loader)
            function execute() {
                alert("hi");
            }
            $(document).ready(
                function () {                
                    $("a").click(
                        function () {
                            if (window.Sys && Sys.loader) {
                                Sys.loader.registerScript("MyScript", null, execute);
                                alert("Lazy loading");
                            }
                            else {
                                execute();
                            }
                        });
                });
        </script>
    
           
        </form>
    
       
    </body>

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 4, 2018 6:14 AM

All replies

  • User-893317190 posted

    Hi karang,

    You should introduce start.js of microsoft.

    Below is my code.

    <head runat="server">
        <title></title>
        <script src="../Scripts/jquery-3.3.1.js"></script>
           <script src="http://ajax.microsoft.com/ajax/beta/0910/Start.js" ></script>
    </head>
    
    <body>
    
        <form id="form1" runat="server">
                   <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            
          <a href="#">click</a>
     <script type="text/javascript">
         console.log(Sys.loader)
            function execute() {
                alert("hi");
            }
            $(document).ready(
                function () {                
                    $("a").click(
                        function () {
                            if (window.Sys && Sys.loader) {
                                Sys.loader.registerScript("MyScript", null, execute);
                                alert("Lazy loading");
                            }
                            else {
                                execute();
                            }
                        });
                });
        </script>
    
           
        </form>
    
       
    </body>

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 4, 2018 6:14 AM
  • User-389597101 posted

    Thank you Ackerly Xu

    Tuesday, September 4, 2018 6:34 AM