jQuery / Javascript execution order?
<p>I'm trying to exactly figure out the execution order of what is going on here. I'm using jquery to retrieve new data, and I get occasional irregularities. How I have its current work flow order should be something like this:</p>

<ol>
<li>Onload - get() function (retrieves data for both divs)</li>
<li>The move() function is activated via a button</li>
<li>move.php has the mysql_query update action</li>
<li>Reload the div with the updated database information.</li>
</ol>

<hr>

<pre><code>function get(varpass) {
    varpass = typeof(varpass) != 'undefined' ? varpass : "all";
    var j = "&lt;?=$_SESSION['username']?&gt;";
    if (varpass == "all" || varpass == "left") {
        $('#left').hide();
        $.get('data.php', {
            name: j,
            p: varpass
        }, function (output) {
            $('#left').html(output).fadeIn(250);
        });
    }
    if (varpass == "all" || varpass == "main") {
        $('#main').hide();
        $.get('main.php', {
            name: j,
            p: varpass
        }, function (output) {
            $('#main').html(output).fadeIn(250);
        });
    }
}
$(document).ready(function () {
    get("all");
});
function move(p) {
    var j = "&lt;?=$_SESSION['username']?&gt;";
    $.get('move.php', {
        name: j,
        p: p
    }, function (output) {
        $('#debug').html(output).fadeIn(1);
    });
    $('#main').hide();
    get("main");
}
</code></pre>

<p>I find that on occasion the div will retrieve information before the move.php mysql_query has been completed. How can control the order of execution better? I want the information to finish being updated before it calls to retrieve the data from the database again.</p>

<p>Thanks</p>
