Google Groups Home
Help | Sign in
Message from discussion How do I get post data to go with it?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Jason Huck  
View profile
 More options May 11, 6:17 pm
From: Jason Huck <jason.h...@gmail.com>
Date: Sun, 11 May 2008 15:17:23 -0700 (PDT)
Local: Sun, May 11 2008 6:17 pm
Subject: Re: How do I get post data to go with it?
You're pretty close, but you don't need *both* $.post() and .load().
Just pick one or the other. Using .load() is a little bit simpler, but
I believe it uses GET behind the scenes:

<script type="text/javascript">
$(function(){
        $('#yourbutton').click(function(){
                $('#submit_result').load('test.php', { input: $('input').val() });
        });

});

</script>

...so if it's important that it be submitted via POST, then something
like this should work:

<script type="text/javascript">
$(function(){
        $('#yourbutton').click(function(){
                $.post('test.php', { input: $('input').val() }, function(data){
                        $('#submit_result').html(data);
                });
        });

});

</script>

HTH,
Jason

On May 11, 3:41 pm, "Jón Helgi Jónsson" <amyth...@gmail.com> wrote:

> Hi,

> I'm new to Jquery.

> I'm trying to send the post data from an input box to test.php however
> it doesn't go over when test.php loads into #submit_result.

> This is what I have so far. What am I doing wrong? I know I am doing
> something dumb.

> <script type="text/javascript">
>   function my_onclick() {
>     $.post("test.php",
>     {input: $("input").val()},
>     function(data) {
>       $("#submit_result").load("test.php");
>     });
>   }
> </script>

> Thanks,
> Jon


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google