PHP and jquery: waiting for $ .post

I have a jquery function that does $ .post values ​​for a php function. This php function then puts this value in $ _SESSION and shows the relevant content.

I would like the execution to not continue until the message is completed, because after $ .post the contents are displayed, and the new value $ _SESSION will not be valid until the next update.

How can i do this?

Thank!

+5
source share
2 answers

What are callbacks for? Pass the function to one of the parameters $.post(), and it will be executed only when the request is successful:

$.post("test.php", function(data) {
   alert("Data Loaded: " + data);
});

document.write('This won`t wait for ajax');

alert() ajax, document.write() , .

+1

, , , .

(javascript) , , (PHP) , (javascript) (PHP), , , (PHP) , , , .

. , ajax ? - , , ? - ?

0

All Articles