Google Groups Home
Help | Sign in
How do I get post data to go with it?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
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
Jón Helgi Jónsson  
View profile
 More options May 11, 3:41 pm
From: "Jón Helgi Jónsson" <amyth...@gmail.com>
Date: Sun, 11 May 2008 19:41:46 +0000
Local: Sun, May 11 2008 3:41 pm
Subject: How do I get post data to go with it?
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.
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:


    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.
Jón Helgi Jónsson  
View profile
 More options May 11, 7:12 pm
From: "Jón Helgi Jónsson" <amyth...@gmail.com>
Date: Sun, 11 May 2008 23:12:49 +0000
Local: Sun, May 11 2008 7:12 pm
Subject: Re: [jQuery] Re: How do I get post data to go with it?
Oh thats beautiful, thank you!


    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.
End of messages
« Back to Discussions « Newer topic     Older topic »

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