Trying To Build A Jquery Success Callback

Trying To Build A Jquery Success Callback

Hey,

I am new to Jquery and am trying to figure out how to create a success callback function that
allows me to only load include files (they are .js format) after my initial action is successful.

Background: I run a site where people answer surveys and once they submit their response a window loads
and displays the results (such as how many total answers as well as a bar graph showing the % of votes for each answer)

This all works fine except for the fact that sometimes the pop up window loads the answer totals WITHOUT counting the new vote. This is because I do not have a way to say "Record vote and when vote is IN, include the process.js file etc"

The file that runs that window (or most of the functions for that 'view results pop up window') is in process.php, which loads right after the $.post function.

Is the solution to spit out json in vote.php, AFTER the vote, and then look for it and then include the files? I just cannot wrap my brain around how this all works, despite reading the docs. Here is the code with a description of what I am trying to do:

  1. <script language="Javascript">

    $('#question_25_button').click(function () {
    var formData3 = $("#firstform_25").serialize();
    $.post("vote.php", $("#firstform_25").serialize());






  2. // The goal is to take the below include files and load them ONLY after
  3. // vote.php records the vote into the database. Otherwise, it loads vote results
  4. // BEFORE the new one is cast. Obviously, that is not acceptable and is due to me
  5. // not having a success callback function as the 3rd parameter.

    <?
    $root=$_SERVER["DOCUMENT_ROOT"];

    include("$root/js/forms/process.js");
    include("$root/js/forms/filter.js");


    ?>
    });

    </script>











Thanks for your time. I know that I need the 3rd paramater for $.post for there to be a success function but I am not sure how to arrange it so I can include an html file that will hold those 2 js files. (For now, this method is a bare bones way of loading those files and I realize it's not perfect. I am here to learn) ;)

Thanks, again.