Trying To Add Function To Jquery Post


I was dropped on the head as a baby, so bear with me.

I know that there can be a 3rd argument for Jquery’s $post. I want to figure out what the best solution is, for a function, that can be used
so we can guarantee that no other jquery functions run until the $post action is completed.

I use $post to hit ‘vote.php’ to submit a vote but I want it to complete this process, and be able to confirm it (Without an annoying alert) so it can properly continue with the process of displaying vote results to the site visitor.

I just am not sure what I should do. What is the best idea, just create a function that displays a ‘please wait’ image that loads for a few seconds and then continue? I just need some help with this simple task so I can finally move on from a project. I just can’t wrap my brain around this simple task for some reason. Please note, my head is sore from all the drops so be kind :wink:

This is how I would do it (demonstrated in abstract terms):{
    showLoadingMessage();'url', {/*data*/}, function() {


I’m not sure if that helps… are you looking for working code? What have you got so far?

TY, James

Here is the actual code I am trying to work with (without that 3rd argument in the original example):

<script language=“Javascript”>

$(‘#upny_sresbtn_25’).click(function () {

var formData3 = $(“#firstform_25”).serialize();

$.post(“vote.php”, $(“#firstform_25”).serialize());





The idea is I created, for test purposes only, a function that alerts a message “Data Loaded” as the 3rd argument. Thing is, I realize an alert is useless.

I guess the goal is something like

function load_waiting_message()

// write load image

// cancel after 1 second, this function only loads after vote.php is successfully posted to


// after this, load process.js and filter.js

Does this help?


Actually, I don’t even need these bells and whistles. I just want somebody to confirm that if I create any function, even if just writes to a db or a log, the process.js/etc won’t load until the vote.php $post action is fully complete.

Will that happen if I just create ANY type of function and add it as the 3rd parameter? I just feel like I am in hell trying to wrap this up after so many hours of work on this monster. It’s killed my business and I just cannot find out a straight answer on google/etc.


Does anybody have any real world experience with something like this? I just want to know how to prevent process.js and the other include file from loading until the $post function is complete.


Please refer to the documentation.

You will see that the success argument is only executed once the Ajax request successfully retrieves the data.

I did. The problem is that when I tried to create a function that does nothing other than an alert, it seemed to work fine. I am a php guy not quite getting the Async concept apparently.

I just figured that all I am doing is sending a vote (I am not producing json afterwards or doing anything…I just send a vote to a db and hope to god I can delay process.js and filter.js from loading until that vote exists)

Should I just create a function called ‘sent_data’ and have it log to another file/db and call that function as the 3rd argument? Would that allow all of those to ensure the vote is sent to vote.php before process.js loads?

Thanks. I know it sounds like a stupid q but it’s not native to me. I’d rather ask a stupid q and learn than continue to be a pickle head. Well, I guess I always will be one so that’s hopeless :wink:

PS. In short, I guess I assumed that if post is told to hit vote.php, and I do my php stuff, that’s all that matters. So what is the ideal way to tell my script “Ok, vote.php did it’s job, move on” without interfering (using alerts for the visitor to read)
with the vote process and pop up display (process.php)


PPS. Yes, I am researching this but I figured I’d ask while I was here…ty, again.

For some background then, you may then find these resources useful.

An Introduction to AJAX [video: 17 mins]
Easy Ajax with jQuery
Build Your Own AJAX Web Applications

The issue is that the concept is new. I just wanted to confirm that any type of success response will ensure the delay in those include files. If so I’ll work to create one. I just wanted to make sure I was grasping what I was reading, that’s all.


Precisely, which is why things such as An Introduction to AJAX help to teach you the concepts of Ajax.

If you don’t like video, there are books such as Build Your Own AJAX Web Applications and [url=“”]Bulletproof Ajax

And if you don’t like books, there are articles such as Easy Ajax with jQuery and [url=“”]Ajax: A New Approach to Web Applications

All of these are ways that you can begin to learn the concepts behind Ajax.

TY. I Think the jquery site has the best doc, the one you linked to. I just have to play with this and re-adjust the way I see things as I am used to the server side of things. It is sort of like going from the U.S to the U.K as a driver…just takes time.

I think way too much with this sort of thing. Have a good night and once I find a solution I will share it…