Sorry I misread your first post.

No matter what you put in the form nothing will be sent because $.post
doesn't "send" a form. You have to explicitly supply it with a JSON
type array/object of values to send.

You may want to check out the Form plugin:

    http://www.malsup.com/jquery/form/

If you prefer DIY then take a look at:

    http://docs.jquery.com/Ajax/serializeArray

There are also a number of tutorials out there, such as:

    http://trevordavis.net/blog/tutorial/ajax-forms-with-jquery/
    http://www.sitepoint.com/article/ajax-jquery/3/

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...

Reply via email to