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:
- echo "<div id='mydiv'>";
- print "Username <input type='text' id='username' value=''/><br>";
- print "<input type='button' id='mybutton' value='Logon'/><p>";
- echo "</div>\n";
- }
- ?>
- <script type="text/javascript" src="<?php echo $JQUERY['jquery.js']; ?>"></script>
- <script type='text/javascript'>
- $("#mybutton").click(function() {
- switch($("#mybutton").attr("value")) {
- case "Logon":
- //works
- //alert("OK");
- //GET works
- //$("#mydiv").load("subscribe.php?username=dummy");
- //POST
- $("#mydiv").load("subscribe.php", {'username' : $("#username")});
- break;
- }
- });
- </script>
FWIW, alert() is displayed, and calling subscribe.php with GET work fine.
Thank you for any hint.