wemustdesign Posted June 9, 2010 Share Posted June 9, 2010 I have a form, I have successfully passed the username from jquery $.post("cplfunctions.php?action=checkUsername", { username: username }, to php script. The php script checks the database to see if the username exists: if ($num >=1){ $status= '0'; }else{ $status= '1'; } How do I pass the variable $status back to the javascript file? Quote Link to comment Share on other sites More sharing options...
trq Posted June 9, 2010 Share Posted June 9, 2010 echo it. Then in jQuery you need to create a function to handle the response. Quote Link to comment Share on other sites More sharing options...
wemustdesign Posted June 10, 2010 Author Share Posted June 10, 2010 Can you point me in the direction of how to create a jquery function to get the response? I know a little php but not 2 good with jquery Quote Link to comment Share on other sites More sharing options...
trq Posted June 10, 2010 Share Posted June 10, 2010 Given your examples: cplfunctions.php if ($num >=1) { $status = '0'; } else { $status = '1'; } ecuo $status; And the jQuery. $.post( "cplfunctions.php?action=checkUsername", { username: username }, function(d) { console.log(d); } ); See http://api.jquery.com/jQuery.post/ for more details. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.