views:

52

answers:

4

Is there any way to get POST values in jQuery?

+3  A: 

jQuery is for client-side Javascript. You grab POST values with server-side languages. You can provide them by mixing server-side with client-side:

<script>
(function() {
 var x = "<?php echo ( isset( $_POST['name'] ) && $_POST['name'] != '') ? $_POST['name'] : '';?>";
})();
</script>
meder
+1  A: 

No, you could use whatever your back-end is to write some hidden fields on the page or write out a javascript script tag with the data, though.

thenduks
A: 

To listen for POST values from another page? Not as far as I know. You can however submit a POST request via ajax to a server-side script and have the server side script return the previously POST-ed values (if you store them in the user's session, for example).

Sean Vieira
A: 

If you use AJAX methods to post you can send back the values or capture them prior to posting via the AJAX.

Mark Schultheiss