Ajax PHP更新无法正常工作

I am trying to update one field through ajax which is not working. below is the code

Jquery:

<script type="text/javascript">
    function changeStatus(changeStatus,userId) {
        var data="changeStatus="+changeStatus+"&userId="+userId;
        $.ajax({
            type:'GET',
            url:'myfunctions.php',
            data:data,
            success:function() {
                alert('Updated');
            }
        });
    }
</script>

php:

<?php
function changeStatus($changeStatus,$userId){
    $userId=$_GET['userId'];
    $userStatus=$_GET['userStatus'];
    switch($userStatus) {
        case "1":
            $changeStatus=0;
            break;
        case "0":
            $changeStatus=1;
            break;
        default:
            $changeStatus="";
    }
    $Query="UPDATE blog_users SET blog_user_status='$changeStatus' WHERE                 blog_user_id='$userId'";
    $Result=mysql_query($Query);
}

if(isset($_GET['userId']) && isset($_GET['userStatus'])) {
    changeStatus($changeStatus,$userId);
}
?>

and here is how i call the function:

<a href="#" onclick="changeStatus($changeStatus,$userId)"><?php echo $action; ?></a>

Just to let know that i tried this only in php by passing get values through href. and it was working...

<a href="#" onclick="changeStatus(<?php echo $changeStatus; ?>,<?php echo $userId; ?>)"><?php echo $action; ?></a>

Try with that

So you are not using the right get variables. In the javascript you set the get variables to changeStatus and userId

var data="changeStatus="+changeStatus+"&userId="+userId;

However in your PHP you get userId and userStatus

$userId=$_GET['userId'];
$userStatus=$_GET['userStatus'];

So $userStatus will never be set since it should $_GET['userStatus']

Since it is empty your query will always look like:

"UPDATE blog_users SET blog_user_status='' WHERE blog_user_id='$userId'";