在ajax JQUERY中传递数据

I'm creating a Login page with ajax and JQuery. Here is my code for ajax:

<script>
    $(document).ready(function() {
        $('#login').click(function(){
            var username=$("#username").val();
            var password=$("#password").val();
            var url = 'username='+username+'&password='+password;
            if($.trim(username).length>0 && $.trim(password).length>0){
                $.ajax({
                    type: "POST",
                    url: "ajaxLogin.php",
                    data: url,
                    cache: false,
                    success: function(responceText){
                        document.write(responceText);
                        if(responceText==1){
                            document.write('____Welcome____');
                        }
                        else if(responceText==0){
                            document.write('____Login Failed____');
                        }
                        else if(responceText == -1){
                            document.write('____Some Thing went wrong____');
                        }
                    }
                });
            }
            return false;
        }); 
    });
</script>

And here is the ajaxLogin class:

<?php
  include("db.php");
  session_start();
  if(isSet($_POST['username']) && isSet($_POST['password'])){
     $username=mysqli_real_escape_string($db,$_POST['username']); 
     $password=md5(mysqli_real_escape_string($db,$_POST['password'])); 
     $result=mysqli_query($db,"SELECT user_id FROM users WHERE user_name='$username' and user_pass='$password'");
     $count=mysqli_num_rows($result);

     $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
        if($count==1) echo 1;
        else echo 0;
     }
     else{
        echo -1;
     }
     ?>

I've debugged the code and i thing the url which i'm passing to the ajax login is not working fine. The values for username and password are null when i load ajaxLogin.php. What is the problem with my url?

var url = 'username='+username+'&password='+password;

is responceText integer ? are you sure about it ? you can try like

                success: function(responceText){
                    responceText = parseInt(responceText);
                    document.write(responceText);

also... you can pass values in better way by construct it as an object...

var url = {
    'username': username,
    'password': password
}

Your url contains data for GET method. For POST you need to pass data like this:

data: {username: username, password: password}