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
2010-07-15 15:45:27
+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
2010-07-15 15:45:42
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
2010-07-15 15:47:17
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
2010-07-15 15:52:46