Simple Jquery POST Question
Posted: Sun Mar 28, 2010 12:11 pm
Hey,
I have a page with 30 survey questions. When the 'submit answer' button is clicked on for each question, 3 things happen:
1.) A vote is sent to the database
2.) process.js is called, which creates a pop up, bar graph and displays the vote results for that question.
3.) They cacn filter results when the pop up is open, so they can view results via demographic
Part 3 works fine. The issue is making sure part 1 (code below) is COMPLETE before part 2 operates. The reason this is critical is because
sometimes, after answering a question, the bar graph loads the results WITHOUT including the most recent vote. This is because my $post function doesn't call a function before it calls on step 2. How can I solve this problem?
Below is the code. I am new to Jquery and this project has taken a lot out of me as I had to learn jquery due to our developer being fired and I am desperate to finish this...below is the code as well as an explanation as to what is going on. In short, I just need a function to be called from the $post command that activates before we call the include file (process.js) and filter.js. Something invisible and silent would be ideal...like a delay.
Thanks for your time.
I have a page with 30 survey questions. When the 'submit answer' button is clicked on for each question, 3 things happen:
1.) A vote is sent to the database
2.) process.js is called, which creates a pop up, bar graph and displays the vote results for that question.
3.) They cacn filter results when the pop up is open, so they can view results via demographic
Part 3 works fine. The issue is making sure part 1 (code below) is COMPLETE before part 2 operates. The reason this is critical is because
sometimes, after answering a question, the bar graph loads the results WITHOUT including the most recent vote. This is because my $post function doesn't call a function before it calls on step 2. How can I solve this problem?
Below is the code. I am new to Jquery and this project has taken a lot out of me as I had to learn jquery due to our developer being fired and I am desperate to finish this...below is the code as well as an explanation as to what is going on. In short, I just need a function to be called from the $post command that activates before we call the include file (process.js) and filter.js. Something invisible and silent would be ideal...like a delay.
Code: Select all
<script language="Javascript">
$('#upny_sresbtn_25').click(function () {
var formData3 = $("#firstform_25").serialize();
$.post("vote.php", $("#firstform_25").serialize());
// The goal is to have a function that prevents the following code from loading
// until the vote is actually submitted to the database. I use php page to load the questions
// and include the 2 javascript files. The system works, other than not having a delay to ensure
// process.js loads AFTER a vote is confirmed sent to the db.
<?
$root=$_SERVER["DOCUMENT_ROOT"];
include("$root/js/forms/process.js");
include("$root/js/forms/filter.js");
?>
});
</script>