Q:

jQuery $.POST only works when some function executed after it.

I have this jQuery project that is almost complete, for the final portion when the user's data has been succeesfully validated, it executes an external PHP script using the $.post function, passing as parameters the user entered info.
My problem though is that my callback function only works if i put an alert function after it.      
Works: 
$.post("backend.php", dataString, 
    function(response) {
        if (response=="1") {
            alert("ok"); 
        }
    }, 'html'); 

alert('test');

But if i don't put that alert after the closing tag, my script doesnt do the alert "ok", or anything else in the callback.
Do any of you see what's wrong w/ my code?
Thanks!

A:

My guess is that there's something that comes after the $.post() script that either causes the page to change or causes the post to be stopped or fail.
Fundamentally, all the alert('test') does is block your code waiting for the OK button to be pressed.  The only way that could make your code suddenly work is if there is something executing in your code after that second alert that messed up the post.
Remember the post is asynchronous.  It will happen in the background while any other code you have runs and only when it succeeds will the alert('ok') run.
So, my guess is that something else in your page is running and messing up the post.

