我能够获得成功消息..!

i am trying to get the user details into database and data is stored..i want a success message to fade in i have tried out some code but sadly its not working...plzz help me out of this..beg u pardon if am wrong.. here gose my register.php code

               <?php
    require_once 'DB_Functions.php';
    $db = new DB_Functions();

    // json response array
    $response = array("error" => false);
    if (!empty($_POST['fname']) && !empty($_POST['lname']) && !empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['mobile'])){
        // receiving the post params
        $fname = trim($_POST['fname']);
        $lname = trim($_POST['lname']);
        $email = trim($_POST['email']);
        $password = $_POST['password'];
        $mobile = trim($_POST['mobile']);

        // validate your email address
        if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
            // valid email address
            if ($db->isUserExisted($email)) {
                // user already existed
                $response["error"] = true;
                $response["error_msg"] = "User already existed with " . $email;
                echo json_encode($response);
            } else {
                // create a new user
                $user = $db->storeUser($fname, $lname, $email, $password, $mobile);
                if ($user) {
                    // user stored successfully
                    $response["error"] = false;
                    $response["uid"] = $user["id"];
                    $response["user"]["fname"] = $user["fname"];
                    $response["user"]["lname"] = $user["lname"];
                    $response["user"]["email"] = $user["email"];
                    $response["user"]["created_at"] = $user["created_at"];
                    $response["user"]["updated_at"] = $user["updated_at"];
                    echo json_encode($response);
                } else {
                    // user failed to store
                    $response["error"] = true;
                    $response["error_msg"] = "Unknown error occurred in registration!";
                    echo json_encode($response);
                }
            }
        } else {
            // invalid email address
            $response["error"] = true;
            $response["error_msg"] = "invalid email address";
            echo json_encode($response);
        }
    } else {
        $response["error"] = true;
        $response["error_msg"] = "Required parameters are missing!";
        echo json_encode($response);
    }
?>

and here gose the .html file with jquery..

              <html>
    <head>
<title>jQuery Test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript" src = "register.js"></script>
 </head>

 <body>

    <!--html body-->
    <form name = "register" id = "register" method = "POST">
        <label>First name:</label>
        <input type = text name = "fname" id = "fname" required>
        <label>Last name:</label>
        <input type = "text" name = "lname" id = "lname" required>
        <label>E-mail:</label>
        <input type = "email" name = "email" id = "email" required>
        <label>Password</label>
        <input type = "password" name = "password" id = "password" required>
        <label>Mobile no:</label>
        <input type = "number" name = "mobile" id = "mobile" required>
        <input type="submit" value="Insert" name="submit" id = "submit">
    </form>
    <div id = "result" align = "right"></div>
</body>
</html>

here gose me /.js/ file

        $(document).ready(function(){

    $("#submit").click(function(e){

        e.preventDefault();

        $.ajax({
            url: "register.php",
            type: "POST",
            data: {
                fname: $("#fname").val(),
                lname: $("#lname").val(),
                email: $("#email").val(),
                password: $("#password").val(),
                mobile: $("#mobile").val()
            },
            dataType: "JSON",
            success: function (json) {
                $("#result").html(json.user.email);  // like that you can display anything inside #result div
                $("#result").fadeOut(1500);

            },
            error: function(jqXHR, textStatus, errorThrown){
                alert(errorThrown);
            }
        });
    });

}); 

There's no need to use JSON.stringify(jsonStr) because jQuery has already parsed the response object for you. jQuery will look at the Content-Type of the response and, if it's application/json, it will parse it, and provide the parsed result to your success handler.

Your jQuery should be like this:

$(document).ready(function(){

    $("#submit").click(function(e){

        e.preventDefault();

        $.ajax({
            url: "register.php",
            type: "POST",
            data: {
                fname: $("#fname").val(),
                lname: $("#lname").val(),
                email: $("#email").val(),
                password: $("#password").val(),
                mobile: $("#mobile").val()
            },
            dataType: "JSON",
            success: function (json){
                if(json.error){
                    $("#result").html(json.error_msg);  // display error message
                }else{
                    $("#result").html(json.user.email);  // like that you can display anything inside #result div
                }
                $("#result").fadeOut(1500);
            },
            error: function(jqXHR, textStatus, errorThrown){
                alert(errorThrown);
            }
        });
    });

});