Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ajaxStart() and ajaxStop dont work

    Hi everyone

    I have the following code which tries to use the ajaxStart and ajaxStop functions and they dont work, any idea ???
    index.html
    Code:
    <html>
        <head>
            <title>in</title>    
            <link rel="stylesheet" type="text/css" href="style.css" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
        </head>
        <body>
                 <div class="loader">
                     <img id="loaderImg" src="loading.gif" alt=""/>
                     <button onclick="unBlockEverything()">Hide</button>
                </div>
                <button onclick="blockEverything()">Show</button>
        </body>
        <script src="update.js" type="text/javascript"></script>
    </html>
    style.css
    Code:
    .body{
        position: relative;
    }
    .loader{
        position: fixed;
        height: 100%;
        width: 100%;
        background-color: rgba(0,0,0,0.725);
        z-index: 1000;
    }
    #loaderImg{
        position: fixed;
        top: 50%; 
        left: 50%;
        margin-top: -100px;
        margin-left: -150px;
    }

    update.js
    Code:
    $(document).ready(function () {
        alert("hi");
        $('.loader').hide();
        $('.loader')
                .ajaxStart(function () {
                    console.log("show1");
                    $(this).show();
                    
                })
                .ajaxStop(function () {
                    $(this).hide();
                    console.log("HIDE2");
                })
                ;
    
    });
    
    function blockEverything(){
        $('#loader').ajaxStart();
        console.log("show");
        
    }
    function unBlockEverything(){
        
        $('#loader').ajaxStop();
        console.log("hide");
    }
    Any help?


    Thank you in advance

  2. #2
    New to the CF scene
    Join Date
    Nov 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Mainly my problem is that i need to run in JavaScript long duration while loop in the background, without freezing the entire web page. I found the ajaxStart which doesnot work in any browser as is presented in the provided code above.

    Any idea?

  3. #3
    Regular Coder
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    365
    Thanks
    1
    Thanked 50 Times in 47 Posts
    Your code is gibberish (mind you I'd say that just because it's jQuery) -- the biggest problem I'm seeing is unterminated strings... I don't know if the forum software screwed with it, but this:

    Code:
    .ajaxStart(function () {
                    console.log("show1               $(this).show();
                    
                })
    You don't see the problem there?
    From time to time the accessibility of websites must be refreshed with the blood of designers and owners; it is its natural manure.
    http://www.cutcodedown.com


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •