HI there, This is the Code which You need , have fun Var Mydata{ Username: $('#username').val(), Password: $('#password').val() }
$.ajax({ url: 'check.php', type: 'POST', data:Mydata // id of the tree dataType: 'html', cache: false, beforeSend: function() {}, error: function(){ // if the datas has not been send }, success: function (txt){ }// end of the success });// end of the .ajax -----Original Message----- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of freech Sent: Wednesday, February 20, 2008 5:35 PM To: jQuery (English) Subject: [jQuery] on form submission, how to decide "on submit: return true / false" Hi there, I got helps and also debugging on self for days on trying to implement a form submission with jQuery, now I was stunk on getting the results from call back .Post or .ajax to pass true & false to the form submission. the code is pretty simple here: $(document).ready(function() { $("#regForm").submit(function() { $.post("check.php", { username: $('#username').val(),password: $ ('#password').val() }, function(data) { $('#errorMessage').html(data); if (data == "pass" ) return true; else return false; //check.php will output { "pass", "user name already token", "input username & password"} //problem here, the true / false value doesn't work. //even if I commented this line and add return false, the form will still be submitted. //I got kind suggestions should try replace $.Post with $.ajax to call here, but don't know how to. }); }); }); the full code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Register</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#regForm").submit(function() { $.post("check.php", { username: $('#username').val(),password: $ ('#password').val() }, function(data) { $('#errorMessage').html(data); if (data == "pass" ) return true; else return false; }); }); }); </script> </head> <body> <form TARGET="<?php echo "$PHP_SELF"; ?>" method="POST" id="regForm"> <p>Username:<input type="text" name="username" id="username" /> <p>Password:<input type="password" name="password" id="password" /> <INPUT TYPE=HIDDEN NAME="stage" VALUE="go"> <p id="errorMessage" style='color:#f00'></p> <input type="submit" name="submit" id="send" value="Sign Up!" /> </form> <?php if ($_POST['stage']=='go') { // do registration & insert user data echo "form submitted"; } //print_r($_POST); ?> </body> </html>