And note that using
alert()
for debugging is always a bad idea. Use console.log().
alert()
will interfere with asynchronous operations, such as ...
$.post()
...
(It will work inside of a $.post() callback as you
have used it - IF it is the only asynchronous callback you have going
simultaneously! And, so, we get back to "the code you haven't
shown us".)