Can't get load() to POST data

Can't get load() to POST data

Hello

I'm a total JS/jQuery newbie, and I'm having a problem using jQuery's load() to POST data to a remote PHP script and rewrite a DIV with whatever the server sent back.

Using a proxy in between, I can see that the JS script isn't sending anything, so I guess there's something wrong in the JS code I send to the browser:

  1. echo "<div id='mydiv'>";
  2. print "Username <input type='text' id='username' value=''/><br>";
  3. print "<input type='button' id='mybutton' value='Logon'/><p>";
  4. echo "</div>\n";
  5. }
  6. ?>

  7. <script type="text/javascript" src="<?php echo $JQUERY['jquery.js']; ?>"></script>

  8. <script type='text/javascript'>
  9. $("#mybutton").click(function() {
  10. switch($("#mybutton").attr("value")) {
  11. case "Logon":
  12.                         //works
  13. //alert("OK");

  14.                         //GET works
  15. //$("#mydiv").load("subscribe.php?username=dummy");

  16. //POST
  17. $("#mydiv").load("subscribe.php", {'username' : $("#username")});
  18. break;
  19. }
  20. });
  21. </script>

FWIW, alert() is displayed, and calling subscribe.php with GET work fine.

Thank you for any hint.