开发者

$.ajax doesn't seem to be working

I'm working on a jQuery-powered registration form, and I'm checking all the input with jQuery, and the only thing left is to see if a user is choosing an already-registered name.

Here's my Ajax request:

 $.ajax({
   type: "POST",
   url: "check_user.php",
   data: "username="+username,
   success: function(){
     errors.push('Your username is taken.');
   }
 });

And check_user.php:

<?php
include_once开发者_开发知识库('../lib/config.php');

$username = $_POST['username'];
$query = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'");
if(mysql_num_rows($query) == 1) {
    header("HTTP/1.1 200 OK");
}

?>

I know the errors.push(); works, because when I was trying to figure out what was wrong with the Ajax request earlier, the 'Username is taken' message was showing up on my registration page whenever I click 'Register'. Now nothing is showing up at all.

Here's all my whole registration page: http://pastebin.org/66815


The file (signup.php) is located at C:\xampp\htdocs\register\user\signup.php

I was using .htaccess and RewriteRule ^signup user/signup.php and viewing it at http://localhost/signup. When I removed that RewriteRule and got to http://localhost/register/user/signup.php, everything worked fine.

So I changed url: "check_user.php" to "url: user/check_user.php" and it all works fine. I didn't know .htaccess was that badass.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜