Sorry, typing too fast, reading too little. Two things are needed:
* $.post needs a callback function so you can get at what is returned. * the submit handler needs a "return false;" so the browser won't continue with the normal submit process. Karl Rudd On Wed, Dec 24, 2008 at 11:54 PM, Brett Alton <brett.jr.al...@gmail.com> wrote: > > Isn't that what $.post is for though? > > $("form#test").bind('submit',(function(){ > $.post("editcustommenu-new.php",{ > menu_bg_colour_selector: $('#menu_bg_colour_selector').val() > });*/ > alert('form submitted'); > }); > > Isn't that supposed to pass 'menu_bg_colour_selector' to $_POST? Or am > I mixing something up... > > My alert seems to work, but the $.post function doesn't seem to pass > anything to my PHP code. > > On Dec 24, 7:40 am, "Karl Rudd" <karl.r...@gmail.com> wrote: >> Unless a submit button is explicitly pressed it's value won't be sent. >> So in the case given, since there are no other form elements, nothing >> with be posted to the server. >> >> Karl Rudd >> >> On Wed, Dec 24, 2008 at 11:36 PM, Brett Alton <brett.jr.al...@gmail.com> >> wrote: >> >> > How do I get PHP to print JavaScript variables via $_POST? jQuery's >> > $.post doesn't seem to be submitting any data. >> >> > This is a sample of what I have... >> >> > test.php: >> > -------------- >> > <?php >> > echo '<pre>'; >> > print_r($_POST); >> > echo '</pre'; >> > ?> >> > <form method="post" action="test.php" id="test"> >> > <input id="submit" name="submit" type="submit" value="Submit"> >> > </form> >> > -------------- >> >> > jquery.js: >> > -------------- >> > $(document).ready(function() >> > { >> > $("form#test").bind('submit',(function(){ >> > $.post("test.php",{ >> > // no matter what I put in here, nothing shows up >> > in test.php >> > }); >> > }); >> > }); >> > -------------- >> >> > I've also tried: >> >> > $("form#test").submit(function(){ >> >> > instead of bind...