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 7 of 7
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts

    capture success document ready

    Hi, i have my divs all set up and all i need to do is capture when this code below has completed and the document is ready.

    I have tried
    Code:
    document.onreadystatechange = function () {
      if (document.readyState == "complete") {
        document.getElementById('endlist').style.display = 'block';
      }
    }
    
     and also 
    
     onSuccess: document.getElementById('endlist').style.display = 'block',
    
    and also 
    
    if(jQuery.isReady)
    {
    showtext();  //show text just has the getElementById display block
    }
    The purpose is when this list is done i need to put some text after it but i am hiding that text until it is done, i already have my divs set up properly i just need to know how to trap this as ready.


    Code:
     
    $(document).ready(function ()
        {
            var client = $().domains({
                 parameters : {
                                   // a list of params
                                     },
                results: "#results",
                loading: "#loader",
                checking: "#checking",
                searchTextbox : "#search_box",
                searchSubmit : "#search_button",
                searchParameter: "domain",
                autoComplete: false,
                
              
                // test code commented out
                //onSuccess: function(data){alert(data)},
                //onError: function(err){alert(err.message);}           
               
            });
        });
    
    //when the doc is ready then display the text inside of 'endlist' div ?
    // at this point how do i capture if the doc is ready
    </script>
    
    thanks
    Last edited by durangod; 12-01-2013 at 05:37 PM.

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    Im not sure I understand. I mean anything you put in $(document).ready(function (){}) will fire, after the document is ready, thats the point.

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    yes and that is what tossed me for a loop as well, because im trying to put a message at the very end of the process and it is giving me a fit. so i thought i would ask because i thought i was doing this right.. thanks for confirming that...

    I will play around with typeof to try to get the value of the div so i can trap that in the process. What im trying to do is if there is value in the div id "results" on success then i want to put a message, but only if there are results.

    I think typeof should work but i know it can be funky when your looking for null or undefined...

    Thanks for the reply and the feedback

  • #4
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    i plugged this into the end of the document ready just before the close brackets just to test it and nothing

    Code:
    /* the value of items is undefined right now at this point */
    var items = document.getElementById('results').value;
    if(!typeof null === 'items' || !typeof undefined === 'items')
    {
    document.write("-- Special Message --");
    }
    im checking to see if the div is not undefined or not null which in that case means there is data in there so i can show my message.

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,642
    Thanks
    6
    Thanked 1,005 Times in 978 Posts
    Please post your entire code (HTML & JS). Where does the domains function come from and what’s its point?

  • #6
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    Here is the whole code and its purpose is to list out available domain names.

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
    <head>
    
    <title>Alternate Checker</title>
    
    <meta name="description" content="" />
    <meta name="keywords" content="" /> 
    
    <link rel="stylesheet" type="text/css" href="stylesheet.css" />
    <link rel="shortcut icon" href="favicon.ico"/>
    
    
     <!-- Fetch jQuery library  -->
        <script src = "/my_js/jquery-1.10.2.min.js"></script>
    
    
        <!-- Fetch DomainsBot plugin  -->
        <script src = "/my_js/jquery.domainsbot.js"></script>
    
    
        <style type="text/css">
            #results>div>a {color:#000000;}
            #results>div>a:hover {color:#535252;}
        </style>
    
    </head>
    <body>
    <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-top:10px;"> 
    <tr valign="top">
    <td>&nbsp;</td>
    
    <td style="margin:0px auto;" >
    <img src="images/top.jpg" border="0" alt="" />
    </td>
    
    <td>&nbsp;</td>
    </tr>
    </table>
    
    <br />
    
    
    <!-- header include -->
    
    <!--#include virtual="includes/header.html" -->
    
    </div>
    
    <!-- page content -->
    
    <table width="80%" cellspacing="0" cellpadding="0" class="midline" align="center">
    <tr valign="top" align="center"> 
    <td style="font-size:large;"> 
    <h2>Alternative Domain Checker</h2>
    </td>
    </tr>
    
    <tr>
    <td style="font-size:large;" align="center">
    <div style="text-align:justify;">
    This is the alternative domain checker.  
    </div>
    <br/>
    <br/>
    <input type="text" id="search_box" />
    <input type="button" id="search_button" value="Check Results"/>
    
    
    <div id="loader"><img src="/images/loading.gif" alt="Loading.." /></div>
    <div id="checking"><img src="/images/checking.gif" alt="Checking.." /></div>
    <br/>
    <br/>
    <div id="results"></div>
    
    <script type="text/javascript">
     
        $(document).ready(function ()
        {
            var client = $().domainsbot({
                 parameters : {
                                    "pageSize" : 50,
                                    "auth-token": "removed for privacy",
                                    "tlds" : "com,biz,net,org,us,info,name,co.uk,ca,tv,mobi,pw,ws,xxx,ltd.uk,me,me.uk,net.uk,org.uk,pic.uk"
                                    },
                results: "#results",
                loading: "#loader",
                checking: "#checking",
                searchTextbox : "#search_box",
                searchSubmit : "#search_button",
                searchParameter: "domain",
                urlCheckout: "removed for privacy",
    
                      /* Events Commented out do not work 
                      onSuccess : function(results){alert(results);} // On success javascript callback
                      onError : function(err){alert(err);} // On error javascript callback
                      onLoading : function(e) {alert(e);} // On loading callback
                      onAvailabilitySuccess : function (res) {alert(res);} // On availability check success callback
                      onAvailabilityError : function (err) {alert(err);} // On availability check error callback
                      */ 
    
                autoComplete: false                      
                           
            });
           
        });
    
    /* this message should only be shown when domains are listed, upon completion of the document output or empty request*/
    document.write("-- End Of List Special Message Needs to be shown --");
    
    </script>
    
    <br />
    <br />
    </td>
    </tr>
    </table>
    <!-- footer -->
    
    <!--#include virtual="includes/footer.html" -->
    
    </body>
    </html>

  • #7
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    nevermind, i was so focused on doing this right after document ready, i had such tunnel vision and determined to do that, i didnt even consider the fact i could do it in the included js file, duh.... lmao

    i found where i could do it before the doc ready and do what i need to do after data is valid... thanks sorry about that..


  •  

    Posting Permissions

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