Hey there MorningZ,

If the script in question was one that took more than a second or two
to complete, I would certainly have kept banging away trying to get
the callback to work.

As far as the callback procedure for load() is concerned - this is
what I had tried -

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", {ASXCode:z});
      doTheRest(z);

}


was changed to bung doTheRest() into the callback for doTheFirst,
thus...

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",
                                   {ASXCode:z},
                                   doTheRest(z)
                                  );
                               }

That is, the call to the last five PHP script loaders was the callback
from the first load().

What ended up happening: absolutely no change from the prior
behaviour: the last five divs were populated before #summDiv.

I also tried explicity calling each of the load() statements in
doTheRest into doTheFirst, thus -

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",
                                   {ASXCode:z},
                                   function() {
                                                  $("#fundDiv").load
("http://www.marketmentat.com/includes/StockFundSum.php";,
{ASXCode:z});
                                                  $("#techDiv").load
("http://www.marketmentat.com/includes/StockTechSum.php";,
{ASXCode:z});
                                                  $("#sensDiv").load
("http://www.marketmentat.com/includes/StockSensSum.php";,
{ASXCode:z});
                                                  $("#optDiv").load
("http://www.marketmentat.com/includes/StockOptSum.php";, {ASXCode:z});
                                                  $("#newsDiv").load
("http://www.marketmentat.com/includes/StockNewsSum.php";,
{ASXCode:z});
                                                  }
                                  );
                             }

Perhaps there is some foo that I didn't try, but all three variants
produced EXACTLY the same behaviour: the last five divs were populated
before #summDiv.

If the callback functionality had worked (as I fully expected it to,
to begin with) I would have saved myself several days of drudgery. If
there's some glaring flaw in how I've implemented it, please let me
know.

Cheers


GT

On Nov 12, 2:22 pm, MorningZ <morni...@gmail.com> wrote:
> Just be aware of the pitfalls of working synchornously.....  your code
> is going to totally lock up the user's browser while it makes the call
> and awaits it return.....
>
> take it or leave it, but the general advice is avoid AJAX w/o the A if
> at all possible
>
> On Nov 11, 10:02 pm, GT <geoffrey.tran...@gmail.com> wrote:
>
> > Hey there Michel,
>
> > I had already nivestigated the various ways of using callbacks, but it
> > seemed that the callback was instantiated before the content was
> > actually traversible.
>
> > The solution was actually on StackOverflow... 
> > athttp://stackoverflow.com/questions/133310/how-can-i-get-jquery-to-per...
>
> > It was obvious the moment I got it through my thick skull that what I
> > wanted to do was 'AJAX without the A'. From there everything fell into
> > place - su much so that it only took me 10 minutes to get th solution
> > implemented.
>
> > Cheers
>
> > GT
>
> > On Nov 6, 6:15 pm, Michel Belleville <michel.bellevi...@gmail.com>
> > wrote:
>
> > > This might help 
> > > :http://docs.jquery.com/Tutorials:Getting_Started_with_jQueryhttp://do...
>
> > > 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>

Reply via email to