Announcement

Collapse
No announcement yet.

Send Data with jQuery $.post()?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Send Data with jQuery $.post()?

    Ok, so i know how to send a post. My problem is, how can i send my data ( in this case a username and password ) to another page, and then get a response displayed in my div "output_"?
    Any help will be much appreciated.
    [mp]251[/mp]
    [warnbox]Don't stand behind me, i might kick.[/warnbox]
    http://www.jquery.com - jQuery - The Write Less, Do more Javascript.
    http://www.php.net - PHP - Official Site for PHP
    http://www.w3schools.com - Tutorials - Tutorials for tons of languages

  • #2
    Code:
    var data = {
        username: $("#username").val(),
        password: $("#pasword").val()
    }
    
    $.post("page.php", data, callback_function);
    
    function callback_function(data) {
        //process return data here
        $("#output").html(data);
    }
    There are lots of examples in the documentation...
    [font='Verdana, Helvetica, sans-serif']ezRPG | pbbg.biz | Boring RPG[/font]

    Comment


    • #3
      Originally posted by Aurora078','index.php?page=Thread&postID=180349#po st180349
      Ok, so i know how to send a post. My problem is, how can i send my data ( in this case a username and password ) to another page, and then get a response displayed in my div "output_"?
      Any help will be much appreciated.
      No offence to you because you are learning and so on.. But this was really lazy.

      The creators off jQuery didn't write a complete documentation on every function and how to use them just for their own amusement?
      http://docs.jquery.com/Main_Page
      If you need any help please shoot me a PM.
      http://davemacaulay.com/

      Comment


      • #4
        Also for this I'd use $.ajax({}); it's possibly a bit more expandable than the post helper.
        "We believe that bad sex and good drugs are the cornerstones of a great democracy."
        - P.A.G.A.N
        Will you be (Mg,Fe)7Si8O22(OH)2 ?



        Comment


        • #5
          Originally posted by Djkanna','index.php?page=Thread&postID=180387#post 180387
          Also for this I'd use $.ajax({}); it's possibly a bit more expandable than the post helper.
          I was thinking of using ajax strictly for the error function it allows that post doesnt.
          [mp]251[/mp]
          [warnbox]Don't stand behind me, i might kick.[/warnbox]
          http://www.jquery.com - jQuery - The Write Less, Do more Javascript.
          http://www.php.net - PHP - Official Site for PHP
          http://www.w3schools.com - Tutorials - Tutorials for tons of languages

          Comment

          Working...
          X