This might help : http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery http://docs.jquery.com/Core/jQuery#callback
Michel Belleville 2009/11/6 GT <geoffrey.tran...@gmail.com> > Hi y'all. > > I have a page that once given an input, goes and loads five DIVs with > content; four of the divs are not visible (they are made visible by a > click on a tab interface). > > What I had tried to do was as folows (given that the code has either > been passed as a POST (the 'asxcode='' gets filled in by <?php echo > $_POST['ASXCode'] ?> ) OR has been entered in the input box #getCode > and the Submit button #hitThat clicked...) > > What I really wanted was for the call to doTheFirst() to populate > #summDiv, and THEN to go and doTheRest; that is, I wanted #summDiv's > content to be completely loaded and fopr the page to be 'navigable'... > and for the rest of the divs to load 'in the background' as it were. > > What I find is that quite often the other divs are loading and are > finished WELL brfore #summDiv is populated (that is, before the call > to StockFullSum.php has fully returned its response). > > Can anybody offer any guidance on this? I attach the javascript (of > course, jquery.js is called before this javascript script is included) > > > Cheers, > > > GT > > here's the script..... > > <script type="text/javascript"> > $(document).ready(function() { > $("ul.tabs").tabs("div.panes > div"); > var asxcode= ''; > if(asxcode!=='') > { > dotheFirst(asxcode); > } > > }); > $("#hitThat").click(function() { > var thisCode=$("#getCode").val(); > dotheFirst(thisCode); > }); > > function dotheFirst(z) { > $("#summDiv").html('<center><img style="margin-top:70px;" > src="http://localhost/WIP/loading.gif" /></center>'); > $("#summDiv").load("http://www.marketmentat.com/includes/ > StockFullSum.php<http://www.marketmentat.com/includes/%0AStockFullSum.php>", > {ASXCode:z}); > doTheRest(z); > } > > > function doTheRest(t){ > $("#fundDiv").load("http://www.marketmentat.com/includes/ > StockFundSum.php<http://www.marketmentat.com/includes/%0AStockFundSum.php>", > {ASXCode:t}); > $("#techDiv").load("http://www.marketmentat.com/includes/ > StockTechSum.php<http://www.marketmentat.com/includes/%0AStockTechSum.php>", > {ASXCode:t}); > $("#sensDiv").load("http://www.marketmentat.com/includes/ > StockSensSum.php<http://www.marketmentat.com/includes/%0AStockSensSum.php>", > {ASXCode:t}); > $("#optDiv").load("http://www.marketmentat.com/includes/ > StockOptSum.php <http://www.marketmentat.com/includes/%0AStockOptSum.php>", > {ASXCode:t}); > $("#newsDiv").load("http://www.marketmentat.com/includes/ > StockNewsSum.php<http://www.marketmentat.com/includes/%0AStockNewsSum.php>", > {ASXCode:t}); > } > > </script> >