Jquery process status box

Posted on 2012-09-12
Last Modified: 2012-09-13
Running into trouble making my page show a processing status on longer winded processes.  The processes dominate and the status cell never has a chance to display.

How can I make the status fade in  work before the show begins?

            //Populates Name, Pay Assgn List and Period List  GOTO:  TOWBFORM/js/fetch-handlers.js:10     fetch and display Name, Active Pay Assgs, and Active Pay Periods  
            'empid' : $("#WfEmpId").val()
            loadPreviousPer();   //GOTO: loadpreviousperiod.js
            loadCurrentPer();    //GOTO: loadcurrentperiod.js
Question by:KeithMcElroy
    LVL 16

    Accepted Solution

    $.fadeIn() has two optional parameters:  speed, and callback.  So you could do something like this - where your populate function is triggered *after* the fadeIn event:

        $("#status").fadeIn("fast", function(){  
                //Populates Name, Pay Assgn List and Period List  GOTO:  TOWBFORM/js/fetch-handlers.js:10     fetch and display Name, Active Pay Assgs, and Active Pay Periods   
                'empid' : $("#WfEmpId").val()

    Open in new window


    Author Comment

    this works really well.  I am fading out at the last line within the fadeIn and that seems to work.
    However, new at this, is that the best place to put the fadeOut?
    Will award points, just wanted to ask this follow up ?
    Thanks a mil!
    LVL 16

    Expert Comment

    Well, it depends - does loadCurrentPer(); or loadPreviousPer();  take a while?  If so, you may consider sticking the fadeOut() at the end of those processes.  Javascript has a preference to plow through every line of code and doesn't necessarily wait for the last line to execute before doing the next - especially if your load functions are doing ajax work.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
    PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now