jQuery.post in WordPress
-
Hi
I have a sign-up form on my website for membership (non wordpress membership). With the validation I want to check if the user name is unique. I have the php code to check this. But How would I get it to check with ajax.
My problem is that I require the wordpress variables etc to locate members in the system.But when I use the Jquery.post nothing is returned or if I point the jQuery.post to a page then I get all the html.
check.php
if(isSet($_POST['username'])) { global $wpdb; $username=$_POST['username']; $accounts = getTableName('accounts'); $sql = "SELECT count(*) as c from $accounts where username = %s"; $sql = $wpdb->prepare($sql, $username); $count = $wpdb->get_var($sql); $isUnique = $count == 0; if ($isUnique) { echo '<span style="color: red;">The username <b>'.$username.'</b> is already in use.</span>'; } else echo 'OK'; }
JQUERY
jQuery.ajax({ type: "POST", url: "check.php", data: "username="+ usr, success: function(msg){
How would this be possible to do..help please!!!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘jQuery.post in WordPress’ is closed to new replies.